<?xml version="1.0" encoding="ascii"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
          "DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
  <title>modbus_tk.simulator</title>
  <link rel="stylesheet" href="epydoc.css" type="text/css" />
  <script type="text/javascript" src="epydoc.js"></script>
</head>

<body bgcolor="white" text="black" link="blue" vlink="#204080"
      alink="#204080">
<!-- ==================== NAVIGATION BAR ==================== -->
<table class="navbar" border="0" width="100%" cellpadding="0"
       bgcolor="#a0c0ff" cellspacing="0">
  <tr valign="middle">

  <!-- Tree link -->
      <th>&nbsp;&nbsp;&nbsp;<a
        href="module-tree.html">Trees</a>&nbsp;&nbsp;&nbsp;</th>

  <!-- Index link -->
      <th>&nbsp;&nbsp;&nbsp;<a
        href="identifier-index.html">Indices</a>&nbsp;&nbsp;&nbsp;</th>

  <!-- Help link -->
      <th>&nbsp;&nbsp;&nbsp;<a
        href="help.html">Help</a>&nbsp;&nbsp;&nbsp;</th>

  <!-- Project homepage -->
      <th class="navbar" align="right" width="100%">
        <table border="0" cellpadding="0" cellspacing="0">
          <tr><th class="navbar" align="center"
            ><a class="navbar" target="_top" href="http://code.google.com/p/modbus-tk/">Modbus Test Kit</a></th>
          </tr></table></th>
  </tr>
</table>
<table width="100%" cellpadding="0" cellspacing="0">
  <tr valign="top">
    <td width="100%">
      <span class="breadcrumbs">
        <a href="modbus_tk-module.html">Package&nbsp;modbus_tk</a> ::
        Module&nbsp;simulator
      </span>
    </td>
    <td>
      <table cellpadding="0" cellspacing="0">
        <!-- hide/show private -->
        <tr><td align="right"><span class="options">[<a href="javascript:void(0);" class="privatelink"
    onclick="toggle_private();">hide&nbsp;private</a>]</span></td></tr>
        <tr><td align="right"><span class="options"
            >[<a href="frames.html" target="_top">frames</a
            >]&nbsp;|&nbsp;<a href="modbus_tk.simulator-pysrc.html"
            target="_top">no&nbsp;frames</a>]</span></td></tr>
      </table>
    </td>
  </tr>
</table>
<h1 class="epydoc">Source Code for <a href="modbus_tk.simulator-module.html">Module modbus_tk.simulator</a></h1>
<pre class="py-src">
<a name="L1"></a><tt class="py-lineno">  1</tt>  <tt class="py-line"><tt class="py-comment">#!/usr/bin/env python</tt> </tt>
<a name="L2"></a><tt class="py-lineno">  2</tt>  <tt class="py-line"><tt class="py-comment"># -*- coding: utf-8 -*-</tt> </tt>
<a name="L3"></a><tt class="py-lineno">  3</tt>  <tt class="py-line"><tt class="py-docstring">"""</tt> </tt>
<a name="L4"></a><tt class="py-lineno">  4</tt>  <tt class="py-line"><tt class="py-docstring"> Modbus TestKit: Implementation of Modbus protocol in python</tt> </tt>
<a name="L5"></a><tt class="py-lineno">  5</tt>  <tt class="py-line"><tt class="py-docstring"></tt> </tt>
<a name="L6"></a><tt class="py-lineno">  6</tt>  <tt class="py-line"><tt class="py-docstring"> (C)2009 - Luc Jean - luc.jean@gmail.com</tt> </tt>
<a name="L7"></a><tt class="py-lineno">  7</tt>  <tt class="py-line"><tt class="py-docstring"> (C)2009 - Apidev - http://www.apidev.fr</tt> </tt>
<a name="L8"></a><tt class="py-lineno">  8</tt>  <tt class="py-line"><tt class="py-docstring"></tt> </tt>
<a name="L9"></a><tt class="py-lineno">  9</tt>  <tt class="py-line"><tt class="py-docstring"> This is distributed under GNU LGPL license, see license.txt</tt> </tt>
<a name="L10"></a><tt class="py-lineno"> 10</tt>  <tt class="py-line"><tt class="py-docstring"></tt> </tt>
<a name="L11"></a><tt class="py-lineno"> 11</tt>  <tt class="py-line"><tt class="py-docstring"> The modbus_tk simulator is a console application which is running a server with TCP and RTU communication</tt> </tt>
<a name="L12"></a><tt class="py-lineno"> 12</tt>  <tt class="py-line"><tt class="py-docstring"> It is possible to interact with the server from the command line or from a RPC (Remote Process Call)</tt> </tt>
<a name="L13"></a><tt class="py-lineno"> 13</tt>  <tt class="py-line"><tt class="py-docstring">"""</tt> </tt>
<a name="L14"></a><tt class="py-lineno"> 14</tt>  <tt class="py-line"> </tt>
<a name="L15"></a><tt class="py-lineno"> 15</tt>  <tt class="py-line"><tt class="py-keyword">import</tt> <tt class="py-name">sys</tt><tt class="py-op">,</tt> <tt class="py-name">os</tt><tt class="py-op">,</tt> <tt class="py-name">time</tt> </tt>
<a name="L16"></a><tt class="py-lineno"> 16</tt>  <tt class="py-line"> </tt>
<a name="L17"></a><tt class="py-lineno"> 17</tt>  <tt class="py-line"><tt class="py-keyword">import</tt> <tt class="py-name">threading</tt> </tt>
<a name="L18"></a><tt class="py-lineno"> 18</tt>  <tt class="py-line"> </tt>
<a name="L19"></a><tt class="py-lineno"> 19</tt>  <tt class="py-line"><tt class="py-keyword">import</tt> <tt id="link-0" class="py-name" targets="Package modbus_tk=modbus_tk-module.html"><a title="modbus_tk" class="py-name" href="#" onclick="return doclink('link-0', 'modbus_tk', 'link-0');">modbus_tk</a></tt> </tt>
<a name="L20"></a><tt class="py-lineno"> 20</tt>  <tt class="py-line"><tt class="py-keyword">import</tt> <tt id="link-1" class="py-name"><a title="modbus_tk" class="py-name" href="#" onclick="return doclink('link-1', 'modbus_tk', 'link-0');">modbus_tk</a></tt><tt class="py-op">.</tt><tt id="link-2" class="py-name" targets="Module modbus_tk.defines=modbus_tk.defines-module.html"><a title="modbus_tk.defines" class="py-name" href="#" onclick="return doclink('link-2', 'defines', 'link-2');">defines</a></tt> <tt class="py-keyword">as</tt> <tt id="link-3" class="py-name"><a title="modbus_tk.defines" class="py-name" href="#" onclick="return doclink('link-3', 'defines', 'link-2');">defines</a></tt> </tt>
<a name="L21"></a><tt class="py-lineno"> 21</tt>  <tt class="py-line"><tt class="py-keyword">import</tt> <tt id="link-4" class="py-name"><a title="modbus_tk" class="py-name" href="#" onclick="return doclink('link-4', 'modbus_tk', 'link-0');">modbus_tk</a></tt><tt class="py-op">.</tt><tt id="link-5" class="py-name" targets="Module modbus_tk.modbus=modbus_tk.modbus-module.html"><a title="modbus_tk.modbus" class="py-name" href="#" onclick="return doclink('link-5', 'modbus', 'link-5');">modbus</a></tt> <tt class="py-keyword">as</tt> <tt id="link-6" class="py-name"><a title="modbus_tk.modbus" class="py-name" href="#" onclick="return doclink('link-6', 'modbus', 'link-5');">modbus</a></tt> </tt>
<a name="L22"></a><tt class="py-lineno"> 22</tt>  <tt class="py-line"><tt class="py-keyword">import</tt> <tt id="link-7" class="py-name"><a title="modbus_tk" class="py-name" href="#" onclick="return doclink('link-7', 'modbus_tk', 'link-0');">modbus_tk</a></tt><tt class="py-op">.</tt><tt id="link-8" class="py-name" targets="Module modbus_tk.modbus_tcp=modbus_tk.modbus_tcp-module.html"><a title="modbus_tk.modbus_tcp" class="py-name" href="#" onclick="return doclink('link-8', 'modbus_tcp', 'link-8');">modbus_tcp</a></tt> <tt class="py-keyword">as</tt> <tt id="link-9" class="py-name"><a title="modbus_tk.modbus_tcp" class="py-name" href="#" onclick="return doclink('link-9', 'modbus_tcp', 'link-8');">modbus_tcp</a></tt> </tt>
<a name="L23"></a><tt class="py-lineno"> 23</tt>  <tt class="py-line"><tt class="py-keyword">import</tt> <tt id="link-10" class="py-name"><a title="modbus_tk" class="py-name" href="#" onclick="return doclink('link-10', 'modbus_tk', 'link-0');">modbus_tk</a></tt><tt class="py-op">.</tt><tt id="link-11" class="py-name" targets="Module modbus_tk.modbus_rtu=modbus_tk.modbus_rtu-module.html"><a title="modbus_tk.modbus_rtu" class="py-name" href="#" onclick="return doclink('link-11', 'modbus_rtu', 'link-11');">modbus_rtu</a></tt> <tt class="py-keyword">as</tt> <tt id="link-12" class="py-name"><a title="modbus_tk.modbus_rtu" class="py-name" href="#" onclick="return doclink('link-12', 'modbus_rtu', 'link-11');">modbus_rtu</a></tt> </tt>
<a name="L24"></a><tt class="py-lineno"> 24</tt>  <tt class="py-line"><tt class="py-keyword">import</tt> <tt class="py-name">serial</tt> </tt>
<a name="L25"></a><tt class="py-lineno"> 25</tt>  <tt class="py-line"><tt class="py-keyword">import</tt> <tt id="link-13" class="py-name"><a title="modbus_tk" class="py-name" href="#" onclick="return doclink('link-13', 'modbus_tk', 'link-0');">modbus_tk</a></tt><tt class="py-op">.</tt><tt id="link-14" class="py-name" targets="Module modbus_tk.hooks=modbus_tk.hooks-module.html"><a title="modbus_tk.hooks" class="py-name" href="#" onclick="return doclink('link-14', 'hooks', 'link-14');">hooks</a></tt> <tt class="py-keyword">as</tt> <tt id="link-15" class="py-name"><a title="modbus_tk.hooks" class="py-name" href="#" onclick="return doclink('link-15', 'hooks', 'link-14');">hooks</a></tt> </tt>
<a name="L26"></a><tt class="py-lineno"> 26</tt>  <tt class="py-line"> </tt>
<a name="L27"></a><tt class="py-lineno"> 27</tt>  <tt class="py-line"><tt class="py-keyword">import</tt> <tt class="py-name">Queue</tt> </tt>
<a name="L28"></a><tt class="py-lineno"> 28</tt>  <tt class="py-line"><tt class="py-keyword">import</tt> <tt class="py-name">SocketServer</tt> </tt>
<a name="L29"></a><tt class="py-lineno"> 29</tt>  <tt class="py-line"><tt class="py-keyword">import</tt> <tt class="py-name">ctypes</tt> </tt>
<a name="L30"></a><tt class="py-lineno"> 30</tt>  <tt class="py-line"> </tt>
<a name="L31"></a><tt class="py-lineno"> 31</tt>  <tt class="py-line"><tt class="py-comment">#add logging capability</tt> </tt>
<a name="L32"></a><tt class="py-lineno"> 32</tt>  <tt class="py-line"><tt id="link-16" class="py-name" targets="Variable modbus_tk.modbus.LOGGER=modbus_tk.modbus-module.html#LOGGER,Variable modbus_tk.modbus_rtu.LOGGER=modbus_tk.modbus_rtu-module.html#LOGGER,Variable modbus_tk.modbus_tcp.LOGGER=modbus_tk.modbus_tcp-module.html#LOGGER,Variable modbus_tk.simulator.LOGGER=modbus_tk.simulator-module.html#LOGGER"><a title="modbus_tk.modbus.LOGGER
modbus_tk.modbus_rtu.LOGGER
modbus_tk.modbus_tcp.LOGGER
modbus_tk.simulator.LOGGER" class="py-name" href="#" onclick="return doclink('link-16', 'LOGGER', 'link-16');">LOGGER</a></tt> <tt class="py-op">=</tt> <tt id="link-17" class="py-name"><a title="modbus_tk" class="py-name" href="#" onclick="return doclink('link-17', 'modbus_tk', 'link-0');">modbus_tk</a></tt><tt class="py-op">.</tt><tt id="link-18" class="py-name" targets="Module modbus_tk.utils=modbus_tk.utils-module.html"><a title="modbus_tk.utils" class="py-name" href="#" onclick="return doclink('link-18', 'utils', 'link-18');">utils</a></tt><tt class="py-op">.</tt><tt id="link-19" class="py-name" targets="Function modbus_tk.utils.create_logger()=modbus_tk.utils-module.html#create_logger"><a title="modbus_tk.utils.create_logger" class="py-name" href="#" onclick="return doclink('link-19', 'create_logger', 'link-19');">create_logger</a></tt><tt class="py-op">(</tt><tt class="py-name">name</tt><tt class="py-op">=</tt><tt class="py-string">"console"</tt><tt class="py-op">,</tt> <tt class="py-name">record_format</tt><tt class="py-op">=</tt><tt class="py-string">"%(message)s"</tt><tt class="py-op">)</tt> </tt>
<a name="L33"></a><tt class="py-lineno"> 33</tt>  <tt class="py-line">         </tt>
<a name="L34"></a><tt class="py-lineno"> 34</tt>  <tt class="py-line"><tt class="py-comment">#The communication between the server and the user interfaces (console or rpc)</tt> </tt>
<a name="L35"></a><tt class="py-lineno"> 35</tt>  <tt class="py-line"><tt class="py-comment">#are done through queues</tt> </tt>
<a name="L36"></a><tt class="py-lineno"> 36</tt>  <tt class="py-line"><tt id="link-20" class="py-name" targets="Variable modbus_tk.simulator.INPUT_QUEUE=modbus_tk.simulator-module.html#INPUT_QUEUE"><a title="modbus_tk.simulator.INPUT_QUEUE" class="py-name" href="#" onclick="return doclink('link-20', 'INPUT_QUEUE', 'link-20');">INPUT_QUEUE</a></tt> <tt class="py-op">=</tt> <tt class="py-name">Queue</tt><tt class="py-op">.</tt><tt class="py-name">Queue</tt><tt class="py-op">(</tt><tt class="py-op">)</tt> <tt class="py-comment">#command received from the interfaces</tt> </tt>
<a name="L37"></a><tt class="py-lineno"> 37</tt>  <tt class="py-line"><tt id="link-21" class="py-name" targets="Variable modbus_tk.simulator.OUTPUT_QUEUE=modbus_tk.simulator-module.html#OUTPUT_QUEUE"><a title="modbus_tk.simulator.OUTPUT_QUEUE" class="py-name" href="#" onclick="return doclink('link-21', 'OUTPUT_QUEUE', 'link-21');">OUTPUT_QUEUE</a></tt> <tt class="py-op">=</tt> <tt class="py-name">Queue</tt><tt class="py-op">.</tt><tt class="py-name">Queue</tt><tt class="py-op">(</tt><tt class="py-op">)</tt> <tt class="py-comment">#response to be sent back by the interfaces</tt> </tt>
<a name="L38"></a><tt class="py-lineno"> 38</tt>  <tt class="py-line"> </tt>
<a name="L39"></a><tt class="py-lineno"> 39</tt>  <tt class="py-line"><tt class="py-comment">#-------------------------------------------------------------------------------</tt> </tt>
<a name="CompositeServer"></a><div id="CompositeServer-def"><a name="L40"></a><tt class="py-lineno"> 40</tt> <a class="py-toggle" href="#" id="CompositeServer-toggle" onclick="return toggle('CompositeServer');">-</a><tt class="py-line"><tt class="py-keyword">class</tt> <a class="py-def-name" href="modbus_tk.simulator.CompositeServer-class.html">CompositeServer</a><tt class="py-op">(</tt><tt class="py-base-class">modbus</tt><tt class="py-op">.</tt><tt class="py-base-class">Server</tt><tt class="py-op">)</tt><tt class="py-op">:</tt> </tt>
</div><div id="CompositeServer-collapsed" style="display:none;" pad="+++" indent="++++"></div><div id="CompositeServer-expanded"><a name="L41"></a><tt class="py-lineno"> 41</tt>  <tt class="py-line">    <tt class="py-docstring">"""make possible to have several servers sharing the same databank"""</tt> </tt>
<a name="L42"></a><tt class="py-lineno"> 42</tt>  <tt class="py-line">     </tt>
<a name="CompositeServer.__init__"></a><div id="CompositeServer.__init__-def"><a name="L43"></a><tt class="py-lineno"> 43</tt> <a class="py-toggle" href="#" id="CompositeServer.__init__-toggle" onclick="return toggle('CompositeServer.__init__');">-</a><tt class="py-line">    <tt class="py-keyword">def</tt> <a class="py-def-name" href="modbus_tk.simulator.CompositeServer-class.html#__init__">__init__</a><tt class="py-op">(</tt><tt class="py-param">self</tt><tt class="py-op">,</tt> <tt class="py-param">list_of_server_classes</tt><tt class="py-op">,</tt> <tt class="py-param">list_of_server_args</tt><tt class="py-op">,</tt> <tt class="py-param">databank</tt><tt class="py-op">=</tt><tt class="py-name">None</tt><tt class="py-op">)</tt><tt class="py-op">:</tt> </tt>
</div><div id="CompositeServer.__init__-collapsed" style="display:none;" pad="+++" indent="++++++++"></div><div id="CompositeServer.__init__-expanded"><a name="L44"></a><tt class="py-lineno"> 44</tt>  <tt class="py-line">        <tt class="py-docstring">"""Constructor"""</tt> </tt>
<a name="L45"></a><tt class="py-lineno"> 45</tt>  <tt class="py-line">        <tt id="link-22" class="py-name"><a title="modbus_tk.modbus" class="py-name" href="#" onclick="return doclink('link-22', 'modbus', 'link-5');">modbus</a></tt><tt class="py-op">.</tt><tt id="link-23" class="py-name" targets="Class modbus_tk.modbus.Server=modbus_tk.modbus.Server-class.html"><a title="modbus_tk.modbus.Server" class="py-name" href="#" onclick="return doclink('link-23', 'Server', 'link-23');">Server</a></tt><tt class="py-op">.</tt><tt id="link-24" class="py-name" targets="Method modbus_tk.modbus.Databank.__init__()=modbus_tk.modbus.Databank-class.html#__init__,Method modbus_tk.modbus.Master.__init__()=modbus_tk.modbus.Master-class.html#__init__,Method modbus_tk.modbus.ModbusBlock.__init__()=modbus_tk.modbus.ModbusBlock-class.html#__init__,Method modbus_tk.modbus.ModbusError.__init__()=modbus_tk.modbus.ModbusError-class.html#__init__,Method modbus_tk.modbus.Query.__init__()=modbus_tk.modbus.Query-class.html#__init__,Method modbus_tk.modbus.Server.__init__()=modbus_tk.modbus.Server-class.html#__init__,Method modbus_tk.modbus.Slave.__init__()=modbus_tk.modbus.Slave-class.html#__init__,Method modbus_tk.modbus_rtu.RtuMaster.__init__()=modbus_tk.modbus_rtu.RtuMaster-class.html#__init__,Method modbus_tk.modbus_rtu.RtuQuery.__init__()=modbus_tk.modbus_rtu.RtuQuery-class.html#__init__,Method modbus_tk.modbus_rtu.RtuServer.__init__()=modbus_tk.modbus_rtu.RtuServer-class.html#__init__,Method modbus_tk.modbus_tcp.ModbusInvalidMbapError.__init__()=modbus_tk.modbus_tcp.ModbusInvalidMbapError-class.html#__init__,Method modbus_tk.modbus_tcp.TcpMaster.__init__()=modbus_tk.modbus_tcp.TcpMaster-class.html#__init__,Method modbus_tk.modbus_tcp.TcpMbap.__init__()=modbus_tk.modbus_tcp.TcpMbap-class.html#__init__,Method modbus_tk.modbus_tcp.TcpQuery.__init__()=modbus_tk.modbus_tcp.TcpQuery-class.html#__init__,Method modbus_tk.modbus_tcp.TcpServer.__init__()=modbus_tk.modbus_tcp.TcpServer-class.html#__init__,Method modbus_tk.simulator.CompositeServer.__init__()=modbus_tk.simulator.CompositeServer-class.html#__init__,Method modbus_tk.simulator.ConsoleInterface.__init__()=modbus_tk.simulator.ConsoleInterface-class.html#__init__,Method modbus_tk.simulator.RpcInterface.__init__()=modbus_tk.simulator.RpcInterface-class.html#__init__,Method modbus_tk.simulator.Simulator.__init__()=modbus_tk.simulator.Simulator-class.html#__init__,Method modbus_tk.simulator_rpc_client.SimulatorRpcClient.__init__()=modbus_tk.simulator_rpc_client.SimulatorRpcClient-class.html#__init__,Method modbus_tk.utils.ConsoleHandler.__init__()=modbus_tk.utils.ConsoleHandler-class.html#__init__,Method modbus_tk.utils.DummyHandler.__init__()=modbus_tk.utils.DummyHandler-class.html#__init__,Method modbus_tk.utils.LogitHandler.__init__()=modbus_tk.utils.LogitHandler-class.html#__init__,Method modbus_tk.utils.WorkerThread.__init__()=modbus_tk.utils.WorkerThread-class.html#__init__"><a title="modbus_tk.modbus.Databank.__init__
modbus_tk.modbus.Master.__init__
modbus_tk.modbus.ModbusBlock.__init__
modbus_tk.modbus.ModbusError.__init__
modbus_tk.modbus.Query.__init__
modbus_tk.modbus.Server.__init__
modbus_tk.modbus.Slave.__init__
modbus_tk.modbus_rtu.RtuMaster.__init__
modbus_tk.modbus_rtu.RtuQuery.__init__
modbus_tk.modbus_rtu.RtuServer.__init__
modbus_tk.modbus_tcp.ModbusInvalidMbapError.__init__
modbus_tk.modbus_tcp.TcpMaster.__init__
modbus_tk.modbus_tcp.TcpMbap.__init__
modbus_tk.modbus_tcp.TcpQuery.__init__
modbus_tk.modbus_tcp.TcpServer.__init__
modbus_tk.simulator.CompositeServer.__init__
modbus_tk.simulator.ConsoleInterface.__init__
modbus_tk.simulator.RpcInterface.__init__
modbus_tk.simulator.Simulator.__init__
modbus_tk.simulator_rpc_client.SimulatorRpcClient.__init__
modbus_tk.utils.ConsoleHandler.__init__
modbus_tk.utils.DummyHandler.__init__
modbus_tk.utils.LogitHandler.__init__
modbus_tk.utils.WorkerThread.__init__" class="py-name" href="#" onclick="return doclink('link-24', '__init__', 'link-24');">__init__</a></tt><tt class="py-op">(</tt><tt class="py-name">self</tt><tt class="py-op">,</tt> <tt class="py-name">databank</tt><tt class="py-op">)</tt> </tt>
<a name="L46"></a><tt class="py-lineno"> 46</tt>  <tt class="py-line">        <tt class="py-name">self</tt><tt class="py-op">.</tt><tt class="py-name">_servers</tt> <tt class="py-op">=</tt> <tt class="py-op">[</tt><tt class="py-name">the_class</tt><tt class="py-op">(</tt><tt class="py-op">*</tt><tt class="py-name">the_args</tt><tt class="py-op">,</tt> <tt class="py-op">**</tt><tt class="py-op">{</tt><tt class="py-string">"databank"</tt><tt class="py-op">:</tt><tt class="py-name">self</tt><tt class="py-op">.</tt><tt id="link-25" class="py-name" targets="Method modbus_tk.modbus.Server.get_db()=modbus_tk.modbus.Server-class.html#get_db"><a title="modbus_tk.modbus.Server.get_db" class="py-name" href="#" onclick="return doclink('link-25', 'get_db', 'link-25');">get_db</a></tt><tt class="py-op">(</tt><tt class="py-op">)</tt><tt class="py-op">}</tt><tt class="py-op">)</tt> </tt>
<a name="L47"></a><tt class="py-lineno"> 47</tt>  <tt class="py-line">                        <tt class="py-keyword">for</tt> <tt class="py-name">the_class</tt><tt class="py-op">,</tt> <tt class="py-name">the_args</tt> </tt>
<a name="L48"></a><tt class="py-lineno"> 48</tt>  <tt class="py-line">                        <tt class="py-keyword">in</tt> <tt class="py-name">zip</tt><tt class="py-op">(</tt><tt class="py-name">list_of_server_classes</tt><tt class="py-op">,</tt> <tt class="py-name">list_of_server_args</tt><tt class="py-op">)</tt> </tt>
<a name="L49"></a><tt class="py-lineno"> 49</tt>  <tt class="py-line">                        <tt class="py-keyword">if</tt> <tt class="py-name">issubclass</tt><tt class="py-op">(</tt><tt class="py-name">the_class</tt><tt class="py-op">,</tt> <tt id="link-26" class="py-name"><a title="modbus_tk.modbus" class="py-name" href="#" onclick="return doclink('link-26', 'modbus', 'link-5');">modbus</a></tt><tt class="py-op">.</tt><tt id="link-27" class="py-name"><a title="modbus_tk.modbus.Server" class="py-name" href="#" onclick="return doclink('link-27', 'Server', 'link-23');">Server</a></tt><tt class="py-op">)</tt><tt class="py-op">]</tt> </tt>
</div><a name="L50"></a><tt class="py-lineno"> 50</tt>  <tt class="py-line">         </tt>
<a name="CompositeServer.set_verbose"></a><div id="CompositeServer.set_verbose-def"><a name="L51"></a><tt class="py-lineno"> 51</tt> <a class="py-toggle" href="#" id="CompositeServer.set_verbose-toggle" onclick="return toggle('CompositeServer.set_verbose');">-</a><tt class="py-line">    <tt class="py-keyword">def</tt> <a class="py-def-name" href="modbus_tk.simulator.CompositeServer-class.html#set_verbose">set_verbose</a><tt class="py-op">(</tt><tt class="py-param">self</tt><tt class="py-op">,</tt> <tt class="py-param">verbose</tt><tt class="py-op">)</tt><tt class="py-op">:</tt> </tt>
</div><div id="CompositeServer.set_verbose-collapsed" style="display:none;" pad="+++" indent="++++++++"></div><div id="CompositeServer.set_verbose-expanded"><a name="L52"></a><tt class="py-lineno"> 52</tt>  <tt class="py-line">        <tt class="py-docstring">"""if verbose is true the sent and received packets will be logged"""</tt> </tt>
<a name="L53"></a><tt class="py-lineno"> 53</tt>  <tt class="py-line">        <tt class="py-keyword">for</tt> <tt class="py-name">srv</tt> <tt class="py-keyword">in</tt> <tt class="py-name">self</tt><tt class="py-op">.</tt><tt class="py-name">_servers</tt><tt class="py-op">:</tt> </tt>
<a name="L54"></a><tt class="py-lineno"> 54</tt>  <tt class="py-line">            <tt class="py-name">srv</tt><tt class="py-op">.</tt><tt id="link-28" class="py-name" targets="Method modbus_tk.modbus.Master.set_verbose()=modbus_tk.modbus.Master-class.html#set_verbose,Method modbus_tk.modbus.Server.set_verbose()=modbus_tk.modbus.Server-class.html#set_verbose,Method modbus_tk.simulator.CompositeServer.set_verbose()=modbus_tk.simulator.CompositeServer-class.html#set_verbose"><a title="modbus_tk.modbus.Master.set_verbose
modbus_tk.modbus.Server.set_verbose
modbus_tk.simulator.CompositeServer.set_verbose" class="py-name" href="#" onclick="return doclink('link-28', 'set_verbose', 'link-28');">set_verbose</a></tt><tt class="py-op">(</tt><tt class="py-name">verbose</tt><tt class="py-op">)</tt> </tt>
</div><a name="L55"></a><tt class="py-lineno"> 55</tt>  <tt class="py-line"> </tt>
<a name="CompositeServer._make_thread"></a><div id="CompositeServer._make_thread-def"><a name="L56"></a><tt class="py-lineno"> 56</tt> <a class="py-toggle" href="#" id="CompositeServer._make_thread-toggle" onclick="return toggle('CompositeServer._make_thread');">-</a><tt class="py-line">    <tt class="py-keyword">def</tt> <a class="py-def-name" href="modbus_tk.simulator.CompositeServer-class.html#_make_thread">_make_thread</a><tt class="py-op">(</tt><tt class="py-param">self</tt><tt class="py-op">)</tt><tt class="py-op">:</tt> </tt>
</div><div id="CompositeServer._make_thread-collapsed" style="display:none;" pad="+++" indent="++++++++"></div><div id="CompositeServer._make_thread-expanded"><a name="L57"></a><tt class="py-lineno"> 57</tt>  <tt class="py-line">        <tt class="py-docstring">"""should initialize the main thread of the server. You don't need it here"""</tt> </tt>
<a name="L58"></a><tt class="py-lineno"> 58</tt>  <tt class="py-line">        <tt class="py-keyword">pass</tt> </tt>
</div><a name="L59"></a><tt class="py-lineno"> 59</tt>  <tt class="py-line"> </tt>
<a name="CompositeServer._make_query"></a><div id="CompositeServer._make_query-def"><a name="L60"></a><tt class="py-lineno"> 60</tt> <a class="py-toggle" href="#" id="CompositeServer._make_query-toggle" onclick="return toggle('CompositeServer._make_query');">-</a><tt class="py-line">    <tt class="py-keyword">def</tt> <a class="py-def-name" href="modbus_tk.simulator.CompositeServer-class.html#_make_query">_make_query</a><tt class="py-op">(</tt><tt class="py-param">self</tt><tt class="py-op">)</tt><tt class="py-op">:</tt> </tt>
</div><div id="CompositeServer._make_query-collapsed" style="display:none;" pad="+++" indent="++++++++"></div><div id="CompositeServer._make_query-expanded"><a name="L61"></a><tt class="py-lineno"> 61</tt>  <tt class="py-line">        <tt class="py-docstring">"""Returns an instance of a Query subclass implementing the MAC layer protocol"""</tt> </tt>
<a name="L62"></a><tt class="py-lineno"> 62</tt>  <tt class="py-line">        <tt class="py-keyword">raise</tt> <tt class="py-name">NotImplementedError</tt><tt class="py-op">(</tt><tt class="py-op">)</tt> </tt>
</div><a name="L63"></a><tt class="py-lineno"> 63</tt>  <tt class="py-line">     </tt>
<a name="L64"></a><tt class="py-lineno"> 64</tt>  <tt class="py-line">     </tt>
<a name="CompositeServer.start"></a><div id="CompositeServer.start-def"><a name="L65"></a><tt class="py-lineno"> 65</tt> <a class="py-toggle" href="#" id="CompositeServer.start-toggle" onclick="return toggle('CompositeServer.start');">-</a><tt class="py-line">    <tt class="py-keyword">def</tt> <a class="py-def-name" href="modbus_tk.simulator.CompositeServer-class.html#start">start</a><tt class="py-op">(</tt><tt class="py-param">self</tt><tt class="py-op">)</tt><tt class="py-op">:</tt> </tt>
</div><div id="CompositeServer.start-collapsed" style="display:none;" pad="+++" indent="++++++++"></div><div id="CompositeServer.start-expanded"><a name="L66"></a><tt class="py-lineno"> 66</tt>  <tt class="py-line">        <tt class="py-docstring">"""Start the server. It will handle request"""</tt> </tt>
<a name="L67"></a><tt class="py-lineno"> 67</tt>  <tt class="py-line">        <tt class="py-keyword">for</tt> <tt class="py-name">srv</tt> <tt class="py-keyword">in</tt> <tt class="py-name">self</tt><tt class="py-op">.</tt><tt class="py-name">_servers</tt><tt class="py-op">:</tt> </tt>
<a name="L68"></a><tt class="py-lineno"> 68</tt>  <tt class="py-line">            <tt class="py-name">srv</tt><tt class="py-op">.</tt><tt id="link-29" class="py-name" targets="Method modbus_tk.modbus.Server.start()=modbus_tk.modbus.Server-class.html#start,Method modbus_tk.simulator.CompositeServer.start()=modbus_tk.simulator.CompositeServer-class.html#start,Method modbus_tk.simulator.Simulator.start()=modbus_tk.simulator.Simulator-class.html#start,Method modbus_tk.utils.WorkerThread.start()=modbus_tk.utils.WorkerThread-class.html#start"><a title="modbus_tk.modbus.Server.start
modbus_tk.simulator.CompositeServer.start
modbus_tk.simulator.Simulator.start
modbus_tk.utils.WorkerThread.start" class="py-name" href="#" onclick="return doclink('link-29', 'start', 'link-29');">start</a></tt><tt class="py-op">(</tt><tt class="py-op">)</tt> </tt>
</div><a name="L69"></a><tt class="py-lineno"> 69</tt>  <tt class="py-line">     </tt>
<a name="CompositeServer.stop"></a><div id="CompositeServer.stop-def"><a name="L70"></a><tt class="py-lineno"> 70</tt> <a class="py-toggle" href="#" id="CompositeServer.stop-toggle" onclick="return toggle('CompositeServer.stop');">-</a><tt class="py-line">    <tt class="py-keyword">def</tt> <a class="py-def-name" href="modbus_tk.simulator.CompositeServer-class.html#stop">stop</a><tt class="py-op">(</tt><tt class="py-param">self</tt><tt class="py-op">)</tt><tt class="py-op">:</tt> </tt>
</div><div id="CompositeServer.stop-collapsed" style="display:none;" pad="+++" indent="++++++++"></div><div id="CompositeServer.stop-expanded"><a name="L71"></a><tt class="py-lineno"> 71</tt>  <tt class="py-line">        <tt class="py-docstring">"""stop the server. It doesn't handle request anymore"""</tt> </tt>
<a name="L72"></a><tt class="py-lineno"> 72</tt>  <tt class="py-line">        <tt class="py-keyword">for</tt> <tt class="py-name">srv</tt> <tt class="py-keyword">in</tt> <tt class="py-name">self</tt><tt class="py-op">.</tt><tt class="py-name">_servers</tt><tt class="py-op">:</tt> </tt>
<a name="L73"></a><tt class="py-lineno"> 73</tt>  <tt class="py-line">            <tt class="py-name">srv</tt><tt class="py-op">.</tt><tt id="link-30" class="py-name" targets="Method modbus_tk.modbus.Server.stop()=modbus_tk.modbus.Server-class.html#stop,Method modbus_tk.modbus_rtu.RtuServer.stop()=modbus_tk.modbus_rtu.RtuServer-class.html#stop,Method modbus_tk.simulator.CompositeServer.stop()=modbus_tk.simulator.CompositeServer-class.html#stop,Method modbus_tk.utils.WorkerThread.stop()=modbus_tk.utils.WorkerThread-class.html#stop"><a title="modbus_tk.modbus.Server.stop
modbus_tk.modbus_rtu.RtuServer.stop
modbus_tk.simulator.CompositeServer.stop
modbus_tk.utils.WorkerThread.stop" class="py-name" href="#" onclick="return doclink('link-30', 'stop', 'link-30');">stop</a></tt><tt class="py-op">(</tt><tt class="py-op">)</tt> </tt>
</div></div><a name="L74"></a><tt class="py-lineno"> 74</tt>  <tt class="py-line"> </tt>
<a name="RpcHandler"></a><div id="RpcHandler-def"><a name="L75"></a><tt class="py-lineno"> 75</tt> <a class="py-toggle" href="#" id="RpcHandler-toggle" onclick="return toggle('RpcHandler');">-</a><tt class="py-line"><tt class="py-keyword">class</tt> <a class="py-def-name" href="modbus_tk.simulator.RpcHandler-class.html">RpcHandler</a><tt class="py-op">(</tt><tt class="py-base-class">SocketServer</tt><tt class="py-op">.</tt><tt class="py-base-class">BaseRequestHandler</tt><tt class="py-op">)</tt><tt class="py-op">:</tt> </tt>
</div><div id="RpcHandler-collapsed" style="display:none;" pad="+++" indent="++++"></div><div id="RpcHandler-expanded"><a name="L76"></a><tt class="py-lineno"> 76</tt>  <tt class="py-line">    <tt class="py-docstring">"""An instance of this class is created every time an RPC call is received by the server"""</tt> </tt>
<a name="L77"></a><tt class="py-lineno"> 77</tt>  <tt class="py-line">     </tt>
<a name="RpcHandler.handle"></a><div id="RpcHandler.handle-def"><a name="L78"></a><tt class="py-lineno"> 78</tt> <a class="py-toggle" href="#" id="RpcHandler.handle-toggle" onclick="return toggle('RpcHandler.handle');">-</a><tt class="py-line">    <tt class="py-keyword">def</tt> <a class="py-def-name" href="modbus_tk.simulator.RpcHandler-class.html#handle">handle</a><tt class="py-op">(</tt><tt class="py-param">self</tt><tt class="py-op">)</tt><tt class="py-op">:</tt> </tt>
</div><div id="RpcHandler.handle-collapsed" style="display:none;" pad="+++" indent="++++++++"></div><div id="RpcHandler.handle-expanded"><a name="L79"></a><tt class="py-lineno"> 79</tt>  <tt class="py-line">        <tt class="py-docstring">"""This function is called automatically by the SocketServer"""</tt> </tt>
<a name="L80"></a><tt class="py-lineno"> 80</tt>  <tt class="py-line">        <tt class="py-comment"># self.request is the TCP socket connected to the client</tt> </tt>
<a name="L81"></a><tt class="py-lineno"> 81</tt>  <tt class="py-line">        <tt class="py-comment"># read the incoming command</tt> </tt>
<a name="L82"></a><tt class="py-lineno"> 82</tt>  <tt class="py-line">        <tt class="py-name">request</tt> <tt class="py-op">=</tt> <tt class="py-name">self</tt><tt class="py-op">.</tt><tt class="py-name">request</tt><tt class="py-op">.</tt><tt class="py-name">recv</tt><tt class="py-op">(</tt><tt class="py-number">1024</tt><tt class="py-op">)</tt><tt class="py-op">.</tt><tt class="py-name">strip</tt><tt class="py-op">(</tt><tt class="py-op">)</tt> </tt>
<a name="L83"></a><tt class="py-lineno"> 83</tt>  <tt class="py-line">        <tt class="py-comment"># write to the queue waiting to be processed by the server</tt> </tt>
<a name="L84"></a><tt class="py-lineno"> 84</tt>  <tt class="py-line">        <tt id="link-31" class="py-name"><a title="modbus_tk.simulator.INPUT_QUEUE" class="py-name" href="#" onclick="return doclink('link-31', 'INPUT_QUEUE', 'link-20');">INPUT_QUEUE</a></tt><tt class="py-op">.</tt><tt class="py-name">put</tt><tt class="py-op">(</tt><tt class="py-name">request</tt><tt class="py-op">)</tt> </tt>
<a name="L85"></a><tt class="py-lineno"> 85</tt>  <tt class="py-line">        <tt class="py-comment"># wait for the server answer in the output queue</tt> </tt>
<a name="L86"></a><tt class="py-lineno"> 86</tt>  <tt class="py-line">        <tt class="py-name">response</tt> <tt class="py-op">=</tt> <tt id="link-32" class="py-name"><a title="modbus_tk.simulator.OUTPUT_QUEUE" class="py-name" href="#" onclick="return doclink('link-32', 'OUTPUT_QUEUE', 'link-21');">OUTPUT_QUEUE</a></tt><tt class="py-op">.</tt><tt class="py-name">get</tt><tt class="py-op">(</tt><tt class="py-name">timeout</tt><tt class="py-op">=</tt><tt class="py-number">5.0</tt><tt class="py-op">)</tt> </tt>
<a name="L87"></a><tt class="py-lineno"> 87</tt>  <tt class="py-line">        <tt class="py-comment"># send back the answer</tt> </tt>
<a name="L88"></a><tt class="py-lineno"> 88</tt>  <tt class="py-line">        <tt class="py-name">self</tt><tt class="py-op">.</tt><tt class="py-name">request</tt><tt class="py-op">.</tt><tt class="py-name">send</tt><tt class="py-op">(</tt><tt class="py-name">response</tt><tt class="py-op">)</tt> </tt>
</div></div><a name="L89"></a><tt class="py-lineno"> 89</tt>  <tt class="py-line"> </tt>
<a name="RpcInterface"></a><div id="RpcInterface-def"><a name="L90"></a><tt class="py-lineno"> 90</tt> <a class="py-toggle" href="#" id="RpcInterface-toggle" onclick="return toggle('RpcInterface');">-</a><tt class="py-line"><tt class="py-keyword">class</tt> <a class="py-def-name" href="modbus_tk.simulator.RpcInterface-class.html">RpcInterface</a><tt class="py-op">(</tt><tt class="py-base-class">threading</tt><tt class="py-op">.</tt><tt class="py-base-class">Thread</tt><tt class="py-op">)</tt><tt class="py-op">:</tt> </tt>
</div><div id="RpcInterface-collapsed" style="display:none;" pad="+++" indent="++++"></div><div id="RpcInterface-expanded"><a name="L91"></a><tt class="py-lineno"> 91</tt>  <tt class="py-line">    <tt class="py-docstring">"""Manage RPC call over TCP/IP thanks to the SocketServer module"""</tt> </tt>
<a name="L92"></a><tt class="py-lineno"> 92</tt>  <tt class="py-line">     </tt>
<a name="RpcInterface.__init__"></a><div id="RpcInterface.__init__-def"><a name="L93"></a><tt class="py-lineno"> 93</tt> <a class="py-toggle" href="#" id="RpcInterface.__init__-toggle" onclick="return toggle('RpcInterface.__init__');">-</a><tt class="py-line">    <tt class="py-keyword">def</tt> <a class="py-def-name" href="modbus_tk.simulator.RpcInterface-class.html#__init__">__init__</a><tt class="py-op">(</tt><tt class="py-param">self</tt><tt class="py-op">)</tt><tt class="py-op">:</tt> </tt>
</div><div id="RpcInterface.__init__-collapsed" style="display:none;" pad="+++" indent="++++++++"></div><div id="RpcInterface.__init__-expanded"><a name="L94"></a><tt class="py-lineno"> 94</tt>  <tt class="py-line">        <tt class="py-docstring">"""Constructor"""</tt> </tt>
<a name="L95"></a><tt class="py-lineno"> 95</tt>  <tt class="py-line">        <tt class="py-name">threading</tt><tt class="py-op">.</tt><tt class="py-name">Thread</tt><tt class="py-op">.</tt><tt id="link-33" class="py-name"><a title="modbus_tk.modbus.Databank.__init__
modbus_tk.modbus.Master.__init__
modbus_tk.modbus.ModbusBlock.__init__
modbus_tk.modbus.ModbusError.__init__
modbus_tk.modbus.Query.__init__
modbus_tk.modbus.Server.__init__
modbus_tk.modbus.Slave.__init__
modbus_tk.modbus_rtu.RtuMaster.__init__
modbus_tk.modbus_rtu.RtuQuery.__init__
modbus_tk.modbus_rtu.RtuServer.__init__
modbus_tk.modbus_tcp.ModbusInvalidMbapError.__init__
modbus_tk.modbus_tcp.TcpMaster.__init__
modbus_tk.modbus_tcp.TcpMbap.__init__
modbus_tk.modbus_tcp.TcpQuery.__init__
modbus_tk.modbus_tcp.TcpServer.__init__
modbus_tk.simulator.CompositeServer.__init__
modbus_tk.simulator.ConsoleInterface.__init__
modbus_tk.simulator.RpcInterface.__init__
modbus_tk.simulator.Simulator.__init__
modbus_tk.simulator_rpc_client.SimulatorRpcClient.__init__
modbus_tk.utils.ConsoleHandler.__init__
modbus_tk.utils.DummyHandler.__init__
modbus_tk.utils.LogitHandler.__init__
modbus_tk.utils.WorkerThread.__init__" class="py-name" href="#" onclick="return doclink('link-33', '__init__', 'link-24');">__init__</a></tt><tt class="py-op">(</tt><tt class="py-name">self</tt><tt class="py-op">)</tt> </tt>
<a name="L96"></a><tt class="py-lineno"> 96</tt>  <tt class="py-line">        <tt class="py-name">self</tt><tt class="py-op">.</tt><tt class="py-name">rpc_server</tt> <tt class="py-op">=</tt> <tt class="py-name">SocketServer</tt><tt class="py-op">.</tt><tt class="py-name">TCPServer</tt><tt class="py-op">(</tt><tt class="py-op">(</tt><tt class="py-string">""</tt><tt class="py-op">,</tt> <tt class="py-number">2711</tt><tt class="py-op">)</tt><tt class="py-op">,</tt> <tt id="link-34" class="py-name" targets="Class modbus_tk.simulator.RpcHandler=modbus_tk.simulator.RpcHandler-class.html"><a title="modbus_tk.simulator.RpcHandler" class="py-name" href="#" onclick="return doclink('link-34', 'RpcHandler', 'link-34');">RpcHandler</a></tt><tt class="py-op">)</tt> </tt>
</div><a name="L97"></a><tt class="py-lineno"> 97</tt>  <tt class="py-line">         </tt>
<a name="RpcInterface.run"></a><div id="RpcInterface.run-def"><a name="L98"></a><tt class="py-lineno"> 98</tt> <a class="py-toggle" href="#" id="RpcInterface.run-toggle" onclick="return toggle('RpcInterface.run');">-</a><tt class="py-line">    <tt class="py-keyword">def</tt> <a class="py-def-name" href="modbus_tk.simulator.RpcInterface-class.html#run">run</a><tt class="py-op">(</tt><tt class="py-param">self</tt><tt class="py-op">)</tt><tt class="py-op">:</tt> </tt>
</div><div id="RpcInterface.run-collapsed" style="display:none;" pad="+++" indent="++++++++"></div><div id="RpcInterface.run-expanded"><a name="L99"></a><tt class="py-lineno"> 99</tt>  <tt class="py-line">        <tt class="py-docstring">"""run the server and wait that it returns"""</tt> </tt>
<a name="L100"></a><tt class="py-lineno">100</tt>  <tt class="py-line">        <tt class="py-name">self</tt><tt class="py-op">.</tt><tt class="py-name">rpc_server</tt><tt class="py-op">.</tt><tt class="py-name">serve_forever</tt><tt class="py-op">(</tt><tt class="py-number">0.5</tt><tt class="py-op">)</tt> </tt>
</div><a name="L101"></a><tt class="py-lineno">101</tt>  <tt class="py-line">         </tt>
<a name="RpcInterface.close"></a><div id="RpcInterface.close-def"><a name="L102"></a><tt class="py-lineno">102</tt> <a class="py-toggle" href="#" id="RpcInterface.close-toggle" onclick="return toggle('RpcInterface.close');">-</a><tt class="py-line">    <tt class="py-keyword">def</tt> <a class="py-def-name" href="modbus_tk.simulator.RpcInterface-class.html#close">close</a><tt class="py-op">(</tt><tt class="py-param">self</tt><tt class="py-op">)</tt><tt class="py-op">:</tt> </tt>
</div><div id="RpcInterface.close-collapsed" style="display:none;" pad="+++" indent="++++++++"></div><div id="RpcInterface.close-expanded"><a name="L103"></a><tt class="py-lineno">103</tt>  <tt class="py-line">        <tt class="py-docstring">"""force the socket server to exit"""</tt> </tt>
<a name="L104"></a><tt class="py-lineno">104</tt>  <tt class="py-line">        <tt class="py-keyword">try</tt><tt class="py-op">:</tt> </tt>
<a name="L105"></a><tt class="py-lineno">105</tt>  <tt class="py-line">            <tt class="py-name">self</tt><tt class="py-op">.</tt><tt class="py-name">rpc_server</tt><tt class="py-op">.</tt><tt class="py-name">shutdown</tt><tt class="py-op">(</tt><tt class="py-op">)</tt> </tt>
<a name="L106"></a><tt class="py-lineno">106</tt>  <tt class="py-line">            <tt class="py-name">self</tt><tt class="py-op">.</tt><tt class="py-name">join</tt><tt class="py-op">(</tt><tt class="py-number">1.0</tt><tt class="py-op">)</tt> </tt>
<a name="L107"></a><tt class="py-lineno">107</tt>  <tt class="py-line">        <tt class="py-keyword">except</tt><tt class="py-op">:</tt> </tt>
<a name="L108"></a><tt class="py-lineno">108</tt>  <tt class="py-line">            <tt id="link-35" class="py-name"><a title="modbus_tk.modbus.LOGGER
modbus_tk.modbus_rtu.LOGGER
modbus_tk.modbus_tcp.LOGGER
modbus_tk.simulator.LOGGER" class="py-name" href="#" onclick="return doclink('link-35', 'LOGGER', 'link-16');">LOGGER</a></tt><tt class="py-op">.</tt><tt class="py-name">warning</tt><tt class="py-op">(</tt><tt class="py-string">"An error occurred while closing RPC interface"</tt><tt class="py-op">)</tt> </tt>
</div></div><a name="L109"></a><tt class="py-lineno">109</tt>  <tt class="py-line"> </tt>
<a name="ConsoleInterface"></a><div id="ConsoleInterface-def"><a name="L110"></a><tt class="py-lineno">110</tt> <a class="py-toggle" href="#" id="ConsoleInterface-toggle" onclick="return toggle('ConsoleInterface');">-</a><tt class="py-line"><tt class="py-keyword">class</tt> <a class="py-def-name" href="modbus_tk.simulator.ConsoleInterface-class.html">ConsoleInterface</a><tt class="py-op">(</tt><tt class="py-base-class">threading</tt><tt class="py-op">.</tt><tt class="py-base-class">Thread</tt><tt class="py-op">)</tt><tt class="py-op">:</tt> </tt>
</div><div id="ConsoleInterface-collapsed" style="display:none;" pad="+++" indent="++++"></div><div id="ConsoleInterface-expanded"><a name="L111"></a><tt class="py-lineno">111</tt>  <tt class="py-line">    <tt class="py-docstring">"""Manage user actions from the console"""</tt> </tt>
<a name="L112"></a><tt class="py-lineno">112</tt>  <tt class="py-line">     </tt>
<a name="ConsoleInterface.__init__"></a><div id="ConsoleInterface.__init__-def"><a name="L113"></a><tt class="py-lineno">113</tt> <a class="py-toggle" href="#" id="ConsoleInterface.__init__-toggle" onclick="return toggle('ConsoleInterface.__init__');">-</a><tt class="py-line">    <tt class="py-keyword">def</tt> <a class="py-def-name" href="modbus_tk.simulator.ConsoleInterface-class.html#__init__">__init__</a><tt class="py-op">(</tt><tt class="py-param">self</tt><tt class="py-op">)</tt><tt class="py-op">:</tt> </tt>
</div><div id="ConsoleInterface.__init__-collapsed" style="display:none;" pad="+++" indent="++++++++"></div><div id="ConsoleInterface.__init__-expanded"><a name="L114"></a><tt class="py-lineno">114</tt>  <tt class="py-line">        <tt class="py-docstring">"""constructor: initialize communication with the console"""</tt> </tt>
<a name="L115"></a><tt class="py-lineno">115</tt>  <tt class="py-line">        <tt class="py-name">threading</tt><tt class="py-op">.</tt><tt class="py-name">Thread</tt><tt class="py-op">.</tt><tt id="link-36" class="py-name"><a title="modbus_tk.modbus.Databank.__init__
modbus_tk.modbus.Master.__init__
modbus_tk.modbus.ModbusBlock.__init__
modbus_tk.modbus.ModbusError.__init__
modbus_tk.modbus.Query.__init__
modbus_tk.modbus.Server.__init__
modbus_tk.modbus.Slave.__init__
modbus_tk.modbus_rtu.RtuMaster.__init__
modbus_tk.modbus_rtu.RtuQuery.__init__
modbus_tk.modbus_rtu.RtuServer.__init__
modbus_tk.modbus_tcp.ModbusInvalidMbapError.__init__
modbus_tk.modbus_tcp.TcpMaster.__init__
modbus_tk.modbus_tcp.TcpMbap.__init__
modbus_tk.modbus_tcp.TcpQuery.__init__
modbus_tk.modbus_tcp.TcpServer.__init__
modbus_tk.simulator.CompositeServer.__init__
modbus_tk.simulator.ConsoleInterface.__init__
modbus_tk.simulator.RpcInterface.__init__
modbus_tk.simulator.Simulator.__init__
modbus_tk.simulator_rpc_client.SimulatorRpcClient.__init__
modbus_tk.utils.ConsoleHandler.__init__
modbus_tk.utils.DummyHandler.__init__
modbus_tk.utils.LogitHandler.__init__
modbus_tk.utils.WorkerThread.__init__" class="py-name" href="#" onclick="return doclink('link-36', '__init__', 'link-24');">__init__</a></tt><tt class="py-op">(</tt><tt class="py-name">self</tt><tt class="py-op">)</tt> </tt>
<a name="L116"></a><tt class="py-lineno">116</tt>  <tt class="py-line">        <tt class="py-name">self</tt><tt class="py-op">.</tt><tt class="py-name">inq</tt> <tt class="py-op">=</tt> <tt id="link-37" class="py-name"><a title="modbus_tk.simulator.INPUT_QUEUE" class="py-name" href="#" onclick="return doclink('link-37', 'INPUT_QUEUE', 'link-20');">INPUT_QUEUE</a></tt> </tt>
<a name="L117"></a><tt class="py-lineno">117</tt>  <tt class="py-line">        <tt class="py-name">self</tt><tt class="py-op">.</tt><tt class="py-name">outq</tt> <tt class="py-op">=</tt> <tt id="link-38" class="py-name"><a title="modbus_tk.simulator.OUTPUT_QUEUE" class="py-name" href="#" onclick="return doclink('link-38', 'OUTPUT_QUEUE', 'link-21');">OUTPUT_QUEUE</a></tt> </tt>
<a name="L118"></a><tt class="py-lineno">118</tt>  <tt class="py-line">        <tt class="py-keyword">if</tt> <tt class="py-name">os</tt><tt class="py-op">.</tt><tt class="py-name">name</tt> <tt class="py-op">==</tt> <tt class="py-string">"nt"</tt><tt class="py-op">:</tt> </tt>
<a name="L119"></a><tt class="py-lineno">119</tt>  <tt class="py-line">            <tt class="py-name">ctypes</tt><tt class="py-op">.</tt><tt class="py-name">windll</tt><tt class="py-op">.</tt><tt class="py-name">Kernel32</tt><tt class="py-op">.</tt><tt class="py-name">GetStdHandle</tt><tt class="py-op">.</tt><tt class="py-name">restype</tt> <tt class="py-op">=</tt> <tt class="py-name">ctypes</tt><tt class="py-op">.</tt><tt class="py-name">c_ulong</tt> </tt>
<a name="L120"></a><tt class="py-lineno">120</tt>  <tt class="py-line">            <tt class="py-name">self</tt><tt class="py-op">.</tt><tt class="py-name">console_handle</tt> <tt class="py-op">=</tt> <tt class="py-name">ctypes</tt><tt class="py-op">.</tt><tt class="py-name">windll</tt><tt class="py-op">.</tt><tt class="py-name">Kernel32</tt><tt class="py-op">.</tt><tt class="py-name">GetStdHandle</tt><tt class="py-op">(</tt><tt class="py-name">ctypes</tt><tt class="py-op">.</tt><tt class="py-name">c_ulong</tt><tt class="py-op">(</tt><tt class="py-number">0xfffffff5</tt><tt class="py-op">)</tt><tt class="py-op">)</tt> </tt>
<a name="L121"></a><tt class="py-lineno">121</tt>  <tt class="py-line">            <tt class="py-name">ctypes</tt><tt class="py-op">.</tt><tt class="py-name">windll</tt><tt class="py-op">.</tt><tt class="py-name">Kernel32</tt><tt class="py-op">.</tt><tt class="py-name">WaitForSingleObject</tt><tt class="py-op">.</tt><tt class="py-name">restype</tt> <tt class="py-op">=</tt> <tt class="py-name">ctypes</tt><tt class="py-op">.</tt><tt class="py-name">c_ulong</tt> </tt>
<a name="L122"></a><tt class="py-lineno">122</tt>  <tt class="py-line">        <tt class="py-keyword">elif</tt> <tt class="py-name">os</tt><tt class="py-op">.</tt><tt class="py-name">name</tt> <tt class="py-op">==</tt> <tt class="py-string">"posix"</tt><tt class="py-op">:</tt> </tt>
<a name="L123"></a><tt class="py-lineno">123</tt>  <tt class="py-line">            <tt class="py-keyword">import</tt> <tt class="py-name">select</tt> </tt>
<a name="L124"></a><tt class="py-lineno">124</tt>  <tt class="py-line">        <tt class="py-keyword">else</tt><tt class="py-op">:</tt> </tt>
<a name="L125"></a><tt class="py-lineno">125</tt>  <tt class="py-line">            <tt class="py-keyword">raise</tt> <tt class="py-name">Exception</tt><tt class="py-op">(</tt><tt class="py-string">"%s platform is not supported yet"</tt> <tt class="py-op">%</tt> <tt class="py-name">os</tt><tt class="py-op">.</tt><tt class="py-name">name</tt><tt class="py-op">)</tt> </tt>
<a name="L126"></a><tt class="py-lineno">126</tt>  <tt class="py-line">        <tt class="py-name">self</tt><tt class="py-op">.</tt><tt class="py-name">_go</tt> <tt class="py-op">=</tt> <tt class="py-name">threading</tt><tt class="py-op">.</tt><tt class="py-name">Event</tt><tt class="py-op">(</tt><tt class="py-op">)</tt> </tt>
<a name="L127"></a><tt class="py-lineno">127</tt>  <tt class="py-line">        <tt class="py-name">self</tt><tt class="py-op">.</tt><tt class="py-name">_go</tt><tt class="py-op">.</tt><tt class="py-name">set</tt><tt class="py-op">(</tt><tt class="py-op">)</tt> </tt>
</div><a name="L128"></a><tt class="py-lineno">128</tt>  <tt class="py-line">         </tt>
<a name="ConsoleInterface._check_console_input"></a><div id="ConsoleInterface._check_console_input-def"><a name="L129"></a><tt class="py-lineno">129</tt> <a class="py-toggle" href="#" id="ConsoleInterface._check_console_input-toggle" onclick="return toggle('ConsoleInterface._check_console_input');">-</a><tt class="py-line">    <tt class="py-keyword">def</tt> <a class="py-def-name" href="modbus_tk.simulator.ConsoleInterface-class.html#_check_console_input">_check_console_input</a><tt class="py-op">(</tt><tt class="py-param">self</tt><tt class="py-op">)</tt><tt class="py-op">:</tt> </tt>
</div><div id="ConsoleInterface._check_console_input-collapsed" style="display:none;" pad="+++" indent="++++++++"></div><div id="ConsoleInterface._check_console_input-expanded"><a name="L130"></a><tt class="py-lineno">130</tt>  <tt class="py-line">        <tt class="py-docstring">"""test if there is something to read on the console"""</tt> </tt>
<a name="L131"></a><tt class="py-lineno">131</tt>  <tt class="py-line">        <tt class="py-keyword">if</tt> <tt class="py-name">os</tt><tt class="py-op">.</tt><tt class="py-name">name</tt> <tt class="py-op">==</tt> <tt class="py-string">"nt"</tt><tt class="py-op">:</tt> </tt>
<a name="L132"></a><tt class="py-lineno">132</tt>  <tt class="py-line">            <tt class="py-keyword">if</tt> <tt class="py-number">0</tt> <tt class="py-op">==</tt> <tt class="py-name">ctypes</tt><tt class="py-op">.</tt><tt class="py-name">windll</tt><tt class="py-op">.</tt><tt class="py-name">Kernel32</tt><tt class="py-op">.</tt><tt class="py-name">WaitForSingleObject</tt><tt class="py-op">(</tt><tt class="py-name">self</tt><tt class="py-op">.</tt><tt class="py-name">console_handle</tt><tt class="py-op">,</tt> <tt class="py-number">500</tt><tt class="py-op">)</tt><tt class="py-op">:</tt> </tt>
<a name="L133"></a><tt class="py-lineno">133</tt>  <tt class="py-line">                <tt class="py-keyword">return</tt> <tt class="py-name">True</tt> </tt>
<a name="L134"></a><tt class="py-lineno">134</tt>  <tt class="py-line">        <tt class="py-keyword">elif</tt> <tt class="py-name">os</tt><tt class="py-op">.</tt><tt class="py-name">name</tt> <tt class="py-op">==</tt> <tt class="py-string">"posix"</tt><tt class="py-op">:</tt> </tt>
<a name="L135"></a><tt class="py-lineno">135</tt>  <tt class="py-line">            <tt class="py-op">(</tt><tt class="py-name">inputready</tt><tt class="py-op">,</tt> <tt class="py-name">abcd</tt><tt class="py-op">,</tt> <tt class="py-name">efgh</tt><tt class="py-op">)</tt> <tt class="py-op">=</tt> <tt class="py-name">select</tt><tt class="py-op">.</tt><tt class="py-name">select</tt><tt class="py-op">(</tt><tt class="py-op">[</tt><tt class="py-name">sys</tt><tt class="py-op">.</tt><tt class="py-name">stdin</tt><tt class="py-op">]</tt><tt class="py-op">,</tt> <tt class="py-op">[</tt><tt class="py-op">]</tt><tt class="py-op">,</tt> <tt class="py-op">[</tt><tt class="py-op">]</tt><tt class="py-op">,</tt> <tt class="py-number">0.5</tt><tt class="py-op">)</tt> </tt>
<a name="L136"></a><tt class="py-lineno">136</tt>  <tt class="py-line">            <tt class="py-keyword">if</tt> <tt class="py-name">len</tt><tt class="py-op">(</tt><tt class="py-name">inputready</tt><tt class="py-op">)</tt><tt class="py-op">&gt;</tt><tt class="py-number">0</tt><tt class="py-op">:</tt> </tt>
<a name="L137"></a><tt class="py-lineno">137</tt>  <tt class="py-line">                <tt class="py-keyword">return</tt> <tt class="py-name">True</tt> </tt>
<a name="L138"></a><tt class="py-lineno">138</tt>  <tt class="py-line">        <tt class="py-keyword">else</tt><tt class="py-op">:</tt> </tt>
<a name="L139"></a><tt class="py-lineno">139</tt>  <tt class="py-line">            <tt class="py-keyword">raise</tt> <tt class="py-name">Exception</tt><tt class="py-op">(</tt><tt class="py-string">"%s platform is not supported yet"</tt> <tt class="py-op">%</tt> <tt class="py-name">os</tt><tt class="py-op">.</tt><tt class="py-name">name</tt><tt class="py-op">)</tt> </tt>
<a name="L140"></a><tt class="py-lineno">140</tt>  <tt class="py-line">        <tt class="py-keyword">return</tt> <tt class="py-name">False</tt> </tt>
</div><a name="L141"></a><tt class="py-lineno">141</tt>  <tt class="py-line">         </tt>
<a name="ConsoleInterface.run"></a><div id="ConsoleInterface.run-def"><a name="L142"></a><tt class="py-lineno">142</tt> <a class="py-toggle" href="#" id="ConsoleInterface.run-toggle" onclick="return toggle('ConsoleInterface.run');">-</a><tt class="py-line">    <tt class="py-keyword">def</tt> <a class="py-def-name" href="modbus_tk.simulator.ConsoleInterface-class.html#run">run</a><tt class="py-op">(</tt><tt class="py-param">self</tt><tt class="py-op">)</tt><tt class="py-op">:</tt> </tt>
</div><div id="ConsoleInterface.run-collapsed" style="display:none;" pad="+++" indent="++++++++"></div><div id="ConsoleInterface.run-expanded"><a name="L143"></a><tt class="py-lineno">143</tt>  <tt class="py-line">        <tt class="py-docstring">"""read from the console, transfer to the server and write the answer"""</tt> </tt>
<a name="L144"></a><tt class="py-lineno">144</tt>  <tt class="py-line">        <tt class="py-keyword">while</tt> <tt class="py-name">self</tt><tt class="py-op">.</tt><tt class="py-name">_go</tt><tt class="py-op">.</tt><tt class="py-name">isSet</tt><tt class="py-op">(</tt><tt class="py-op">)</tt><tt class="py-op">:</tt> <tt class="py-comment">#while app is running</tt> </tt>
<a name="L145"></a><tt class="py-lineno">145</tt>  <tt class="py-line">            <tt class="py-keyword">if</tt> <tt class="py-name">self</tt><tt class="py-op">.</tt><tt id="link-39" class="py-name" targets="Method modbus_tk.simulator.ConsoleInterface._check_console_input()=modbus_tk.simulator.ConsoleInterface-class.html#_check_console_input"><a title="modbus_tk.simulator.ConsoleInterface._check_console_input" class="py-name" href="#" onclick="return doclink('link-39', '_check_console_input', 'link-39');">_check_console_input</a></tt><tt class="py-op">(</tt><tt class="py-op">)</tt><tt class="py-op">:</tt> <tt class="py-comment">#if something to read on the console</tt> </tt>
<a name="L146"></a><tt class="py-lineno">146</tt>  <tt class="py-line">                <tt class="py-name">cmd</tt> <tt class="py-op">=</tt> <tt class="py-name">sys</tt><tt class="py-op">.</tt><tt class="py-name">stdin</tt><tt class="py-op">.</tt><tt class="py-name">readline</tt><tt class="py-op">(</tt><tt class="py-op">)</tt> <tt class="py-comment">#read it</tt> </tt>
<a name="L147"></a><tt class="py-lineno">147</tt>  <tt class="py-line">                <tt class="py-name">self</tt><tt class="py-op">.</tt><tt class="py-name">inq</tt><tt class="py-op">.</tt><tt class="py-name">put</tt><tt class="py-op">(</tt><tt class="py-name">cmd</tt><tt class="py-op">)</tt> <tt class="py-comment">#dispatch it tpo the server</tt> </tt>
<a name="L148"></a><tt class="py-lineno">148</tt>  <tt class="py-line">                <tt class="py-name">response</tt> <tt class="py-op">=</tt> <tt class="py-name">self</tt><tt class="py-op">.</tt><tt class="py-name">outq</tt><tt class="py-op">.</tt><tt class="py-name">get</tt><tt class="py-op">(</tt><tt class="py-name">timeout</tt><tt class="py-op">=</tt><tt class="py-number">2.0</tt><tt class="py-op">)</tt> <tt class="py-comment">#wait for an answer</tt> </tt>
<a name="L149"></a><tt class="py-lineno">149</tt>  <tt class="py-line">                <tt class="py-name">sys</tt><tt class="py-op">.</tt><tt class="py-name">stdout</tt><tt class="py-op">.</tt><tt class="py-name">write</tt><tt class="py-op">(</tt><tt class="py-name">response</tt><tt class="py-op">)</tt> <tt class="py-comment">#write the answer on the console</tt> </tt>
</div><a name="L150"></a><tt class="py-lineno">150</tt>  <tt class="py-line">         </tt>
<a name="ConsoleInterface.close"></a><div id="ConsoleInterface.close-def"><a name="L151"></a><tt class="py-lineno">151</tt> <a class="py-toggle" href="#" id="ConsoleInterface.close-toggle" onclick="return toggle('ConsoleInterface.close');">-</a><tt class="py-line">    <tt class="py-keyword">def</tt> <a class="py-def-name" href="modbus_tk.simulator.ConsoleInterface-class.html#close">close</a><tt class="py-op">(</tt><tt class="py-param">self</tt><tt class="py-op">)</tt><tt class="py-op">:</tt> </tt>
</div><div id="ConsoleInterface.close-collapsed" style="display:none;" pad="+++" indent="++++++++"></div><div id="ConsoleInterface.close-expanded"><a name="L152"></a><tt class="py-lineno">152</tt>  <tt class="py-line">        <tt class="py-docstring">"""terminates the thread"""</tt> </tt>
<a name="L153"></a><tt class="py-lineno">153</tt>  <tt class="py-line">        <tt class="py-name">self</tt><tt class="py-op">.</tt><tt class="py-name">_go</tt><tt class="py-op">.</tt><tt class="py-name">clear</tt><tt class="py-op">(</tt><tt class="py-op">)</tt> </tt>
<a name="L154"></a><tt class="py-lineno">154</tt>  <tt class="py-line">        <tt class="py-name">self</tt><tt class="py-op">.</tt><tt class="py-name">join</tt><tt class="py-op">(</tt><tt class="py-number">1.0</tt><tt class="py-op">)</tt> </tt>
</div></div><a name="L155"></a><tt class="py-lineno">155</tt>  <tt class="py-line"> </tt>
<a name="Simulator"></a><div id="Simulator-def"><a name="L156"></a><tt class="py-lineno">156</tt> <a class="py-toggle" href="#" id="Simulator-toggle" onclick="return toggle('Simulator');">-</a><tt class="py-line"><tt class="py-keyword">class</tt> <a class="py-def-name" href="modbus_tk.simulator.Simulator-class.html">Simulator</a><tt class="py-op">:</tt> </tt>
</div><div id="Simulator-collapsed" style="display:none;" pad="+++" indent="++++"></div><div id="Simulator-expanded"><a name="L157"></a><tt class="py-lineno">157</tt>  <tt class="py-line">    <tt class="py-docstring">"""The main class of the app in charge of running everything"""</tt> </tt>
<a name="L158"></a><tt class="py-lineno">158</tt>  <tt class="py-line">     </tt>
<a name="Simulator.__init__"></a><div id="Simulator.__init__-def"><a name="L159"></a><tt class="py-lineno">159</tt> <a class="py-toggle" href="#" id="Simulator.__init__-toggle" onclick="return toggle('Simulator.__init__');">-</a><tt class="py-line">    <tt class="py-keyword">def</tt> <a class="py-def-name" href="modbus_tk.simulator.Simulator-class.html#__init__">__init__</a><tt class="py-op">(</tt><tt class="py-param">self</tt><tt class="py-op">,</tt> <tt class="py-param">server</tt><tt class="py-op">=</tt><tt class="py-name">None</tt><tt class="py-op">)</tt><tt class="py-op">:</tt> </tt>
</div><div id="Simulator.__init__-collapsed" style="display:none;" pad="+++" indent="++++++++"></div><div id="Simulator.__init__-expanded"><a name="L160"></a><tt class="py-lineno">160</tt>  <tt class="py-line">        <tt class="py-docstring">"""Constructor"""</tt> </tt>
<a name="L161"></a><tt class="py-lineno">161</tt>  <tt class="py-line">        <tt class="py-keyword">if</tt> <tt class="py-name">server</tt> <tt class="py-op">==</tt> <tt class="py-name">None</tt><tt class="py-op">:</tt> </tt>
<a name="L162"></a><tt class="py-lineno">162</tt>  <tt class="py-line">            <tt class="py-name">self</tt><tt class="py-op">.</tt><tt class="py-name">server</tt> <tt class="py-op">=</tt> <tt id="link-40" class="py-name" targets="Class modbus_tk.simulator.CompositeServer=modbus_tk.simulator.CompositeServer-class.html"><a title="modbus_tk.simulator.CompositeServer" class="py-name" href="#" onclick="return doclink('link-40', 'CompositeServer', 'link-40');">CompositeServer</a></tt><tt class="py-op">(</tt><tt class="py-op">[</tt><tt id="link-41" class="py-name"><a title="modbus_tk.modbus_rtu" class="py-name" href="#" onclick="return doclink('link-41', 'modbus_rtu', 'link-11');">modbus_rtu</a></tt><tt class="py-op">.</tt><tt id="link-42" class="py-name" targets="Class modbus_tk.modbus_rtu.RtuServer=modbus_tk.modbus_rtu.RtuServer-class.html"><a title="modbus_tk.modbus_rtu.RtuServer" class="py-name" href="#" onclick="return doclink('link-42', 'RtuServer', 'link-42');">RtuServer</a></tt><tt class="py-op">,</tt> <tt id="link-43" class="py-name"><a title="modbus_tk.modbus_tcp" class="py-name" href="#" onclick="return doclink('link-43', 'modbus_tcp', 'link-8');">modbus_tcp</a></tt><tt class="py-op">.</tt><tt id="link-44" class="py-name" targets="Class modbus_tk.modbus_tcp.TcpServer=modbus_tk.modbus_tcp.TcpServer-class.html"><a title="modbus_tk.modbus_tcp.TcpServer" class="py-name" href="#" onclick="return doclink('link-44', 'TcpServer', 'link-44');">TcpServer</a></tt><tt class="py-op">]</tt><tt class="py-op">,</tt> <tt class="py-op">[</tt><tt class="py-op">(</tt><tt class="py-name">serial</tt><tt class="py-op">.</tt><tt class="py-name">Serial</tt><tt class="py-op">(</tt><tt class="py-number">0</tt><tt class="py-op">)</tt><tt class="py-op">,</tt><tt class="py-op">)</tt><tt class="py-op">,</tt> <tt class="py-op">(</tt><tt class="py-op">)</tt><tt class="py-op">]</tt><tt class="py-op">)</tt> </tt>
<a name="L163"></a><tt class="py-lineno">163</tt>  <tt class="py-line">        <tt class="py-keyword">else</tt><tt class="py-op">:</tt> </tt>
<a name="L164"></a><tt class="py-lineno">164</tt>  <tt class="py-line">            <tt class="py-name">self</tt><tt class="py-op">.</tt><tt class="py-name">server</tt> <tt class="py-op">=</tt> <tt class="py-name">server</tt> </tt>
<a name="L165"></a><tt class="py-lineno">165</tt>  <tt class="py-line">        <tt class="py-name">self</tt><tt class="py-op">.</tt><tt class="py-name">rpc</tt> <tt class="py-op">=</tt> <tt id="link-45" class="py-name" targets="Class modbus_tk.simulator.RpcInterface=modbus_tk.simulator.RpcInterface-class.html"><a title="modbus_tk.simulator.RpcInterface" class="py-name" href="#" onclick="return doclink('link-45', 'RpcInterface', 'link-45');">RpcInterface</a></tt><tt class="py-op">(</tt><tt class="py-op">)</tt> </tt>
<a name="L166"></a><tt class="py-lineno">166</tt>  <tt class="py-line">        <tt class="py-name">self</tt><tt class="py-op">.</tt><tt class="py-name">console</tt> <tt class="py-op">=</tt> <tt id="link-46" class="py-name" targets="Class modbus_tk.simulator.ConsoleInterface=modbus_tk.simulator.ConsoleInterface-class.html"><a title="modbus_tk.simulator.ConsoleInterface" class="py-name" href="#" onclick="return doclink('link-46', 'ConsoleInterface', 'link-46');">ConsoleInterface</a></tt><tt class="py-op">(</tt><tt class="py-op">)</tt> </tt>
<a name="L167"></a><tt class="py-lineno">167</tt>  <tt class="py-line">        <tt class="py-name">self</tt><tt class="py-op">.</tt><tt class="py-name">inq</tt><tt class="py-op">,</tt> <tt class="py-name">self</tt><tt class="py-op">.</tt><tt class="py-name">outq</tt> <tt class="py-op">=</tt> <tt id="link-47" class="py-name"><a title="modbus_tk.simulator.INPUT_QUEUE" class="py-name" href="#" onclick="return doclink('link-47', 'INPUT_QUEUE', 'link-20');">INPUT_QUEUE</a></tt><tt class="py-op">,</tt> <tt id="link-48" class="py-name"><a title="modbus_tk.simulator.OUTPUT_QUEUE" class="py-name" href="#" onclick="return doclink('link-48', 'OUTPUT_QUEUE', 'link-21');">OUTPUT_QUEUE</a></tt> </tt>
<a name="L168"></a><tt class="py-lineno">168</tt>  <tt class="py-line">        <tt class="py-name">self</tt><tt class="py-op">.</tt><tt class="py-name">_hooks_fct</tt> <tt class="py-op">=</tt> <tt class="py-op">{</tt><tt class="py-op">}</tt> </tt>
<a name="L169"></a><tt class="py-lineno">169</tt>  <tt class="py-line"> </tt>
<a name="L170"></a><tt class="py-lineno">170</tt>  <tt class="py-line">        <tt class="py-name">self</tt><tt class="py-op">.</tt><tt class="py-name">cmds</tt> <tt class="py-op">=</tt> <tt class="py-op">{</tt><tt class="py-string">"add_slave"</tt><tt class="py-op">:</tt><tt class="py-name">self</tt><tt class="py-op">.</tt><tt id="link-49" class="py-name" targets="Method modbus_tk.simulator.Simulator._do_add_slave()=modbus_tk.simulator.Simulator-class.html#_do_add_slave"><a title="modbus_tk.simulator.Simulator._do_add_slave" class="py-name" href="#" onclick="return doclink('link-49', '_do_add_slave', 'link-49');">_do_add_slave</a></tt><tt class="py-op">,</tt> </tt>
<a name="L171"></a><tt class="py-lineno">171</tt>  <tt class="py-line">                <tt class="py-string">"has_slave"</tt><tt class="py-op">:</tt><tt class="py-name">self</tt><tt class="py-op">.</tt><tt id="link-50" class="py-name" targets="Method modbus_tk.simulator.Simulator._do_has_slave()=modbus_tk.simulator.Simulator-class.html#_do_has_slave"><a title="modbus_tk.simulator.Simulator._do_has_slave" class="py-name" href="#" onclick="return doclink('link-50', '_do_has_slave', 'link-50');">_do_has_slave</a></tt><tt class="py-op">,</tt> </tt>
<a name="L172"></a><tt class="py-lineno">172</tt>  <tt class="py-line">                <tt class="py-string">"remove_slave"</tt><tt class="py-op">:</tt><tt class="py-name">self</tt><tt class="py-op">.</tt><tt id="link-51" class="py-name" targets="Method modbus_tk.simulator.Simulator._do_remove_slave()=modbus_tk.simulator.Simulator-class.html#_do_remove_slave"><a title="modbus_tk.simulator.Simulator._do_remove_slave" class="py-name" href="#" onclick="return doclink('link-51', '_do_remove_slave', 'link-51');">_do_remove_slave</a></tt><tt class="py-op">,</tt> </tt>
<a name="L173"></a><tt class="py-lineno">173</tt>  <tt class="py-line">                <tt class="py-string">"remove_all_slaves"</tt><tt class="py-op">:</tt><tt class="py-name">self</tt><tt class="py-op">.</tt><tt id="link-52" class="py-name" targets="Method modbus_tk.simulator.Simulator._do_remove_all_slaves()=modbus_tk.simulator.Simulator-class.html#_do_remove_all_slaves"><a title="modbus_tk.simulator.Simulator._do_remove_all_slaves" class="py-name" href="#" onclick="return doclink('link-52', '_do_remove_all_slaves', 'link-52');">_do_remove_all_slaves</a></tt><tt class="py-op">,</tt> </tt>
<a name="L174"></a><tt class="py-lineno">174</tt>  <tt class="py-line">                <tt class="py-string">"add_block"</tt><tt class="py-op">:</tt><tt class="py-name">self</tt><tt class="py-op">.</tt><tt id="link-53" class="py-name" targets="Method modbus_tk.simulator.Simulator._do_add_block()=modbus_tk.simulator.Simulator-class.html#_do_add_block"><a title="modbus_tk.simulator.Simulator._do_add_block" class="py-name" href="#" onclick="return doclink('link-53', '_do_add_block', 'link-53');">_do_add_block</a></tt><tt class="py-op">,</tt> </tt>
<a name="L175"></a><tt class="py-lineno">175</tt>  <tt class="py-line">                <tt class="py-string">"remove_block"</tt><tt class="py-op">:</tt><tt class="py-name">self</tt><tt class="py-op">.</tt><tt id="link-54" class="py-name" targets="Method modbus_tk.simulator.Simulator._do_remove_block()=modbus_tk.simulator.Simulator-class.html#_do_remove_block"><a title="modbus_tk.simulator.Simulator._do_remove_block" class="py-name" href="#" onclick="return doclink('link-54', '_do_remove_block', 'link-54');">_do_remove_block</a></tt><tt class="py-op">,</tt> </tt>
<a name="L176"></a><tt class="py-lineno">176</tt>  <tt class="py-line">                <tt class="py-string">"remove_all_blocks"</tt><tt class="py-op">:</tt><tt class="py-name">self</tt><tt class="py-op">.</tt><tt id="link-55" class="py-name" targets="Method modbus_tk.simulator.Simulator._do_remove_all_blocks()=modbus_tk.simulator.Simulator-class.html#_do_remove_all_blocks"><a title="modbus_tk.simulator.Simulator._do_remove_all_blocks" class="py-name" href="#" onclick="return doclink('link-55', '_do_remove_all_blocks', 'link-55');">_do_remove_all_blocks</a></tt><tt class="py-op">,</tt> </tt>
<a name="L177"></a><tt class="py-lineno">177</tt>  <tt class="py-line">                <tt class="py-string">"set_values"</tt><tt class="py-op">:</tt><tt class="py-name">self</tt><tt class="py-op">.</tt><tt id="link-56" class="py-name" targets="Method modbus_tk.simulator.Simulator._do_set_values()=modbus_tk.simulator.Simulator-class.html#_do_set_values"><a title="modbus_tk.simulator.Simulator._do_set_values" class="py-name" href="#" onclick="return doclink('link-56', '_do_set_values', 'link-56');">_do_set_values</a></tt><tt class="py-op">,</tt> </tt>
<a name="L178"></a><tt class="py-lineno">178</tt>  <tt class="py-line">                <tt class="py-string">"get_values"</tt><tt class="py-op">:</tt><tt class="py-name">self</tt><tt class="py-op">.</tt><tt id="link-57" class="py-name" targets="Method modbus_tk.simulator.Simulator._do_get_values()=modbus_tk.simulator.Simulator-class.html#_do_get_values"><a title="modbus_tk.simulator.Simulator._do_get_values" class="py-name" href="#" onclick="return doclink('link-57', '_do_get_values', 'link-57');">_do_get_values</a></tt><tt class="py-op">,</tt> </tt>
<a name="L179"></a><tt class="py-lineno">179</tt>  <tt class="py-line">                <tt class="py-string">"install_hook"</tt><tt class="py-op">:</tt><tt class="py-name">self</tt><tt class="py-op">.</tt><tt id="link-58" class="py-name" targets="Method modbus_tk.simulator.Simulator._do_install_hook()=modbus_tk.simulator.Simulator-class.html#_do_install_hook"><a title="modbus_tk.simulator.Simulator._do_install_hook" class="py-name" href="#" onclick="return doclink('link-58', '_do_install_hook', 'link-58');">_do_install_hook</a></tt><tt class="py-op">,</tt> </tt>
<a name="L180"></a><tt class="py-lineno">180</tt>  <tt class="py-line">                <tt class="py-string">"uninstall_hook"</tt><tt class="py-op">:</tt><tt class="py-name">self</tt><tt class="py-op">.</tt><tt id="link-59" class="py-name" targets="Method modbus_tk.simulator.Simulator._do_uninstall_hook()=modbus_tk.simulator.Simulator-class.html#_do_uninstall_hook"><a title="modbus_tk.simulator.Simulator._do_uninstall_hook" class="py-name" href="#" onclick="return doclink('link-59', '_do_uninstall_hook', 'link-59');">_do_uninstall_hook</a></tt><tt class="py-op">,</tt> </tt>
<a name="L181"></a><tt class="py-lineno">181</tt>  <tt class="py-line">                <tt class="py-string">"set_verbose"</tt><tt class="py-op">:</tt><tt class="py-name">self</tt><tt class="py-op">.</tt><tt id="link-60" class="py-name" targets="Method modbus_tk.simulator.Simulator._do_set_verbose()=modbus_tk.simulator.Simulator-class.html#_do_set_verbose"><a title="modbus_tk.simulator.Simulator._do_set_verbose" class="py-name" href="#" onclick="return doclink('link-60', '_do_set_verbose', 'link-60');">_do_set_verbose</a></tt><tt class="py-op">,</tt> </tt>
<a name="L182"></a><tt class="py-lineno">182</tt>  <tt class="py-line">                <tt class="py-op">}</tt> </tt>
</div><a name="L183"></a><tt class="py-lineno">183</tt>  <tt class="py-line"> </tt>
<a name="Simulator.add_command"></a><div id="Simulator.add_command-def"><a name="L184"></a><tt class="py-lineno">184</tt> <a class="py-toggle" href="#" id="Simulator.add_command-toggle" onclick="return toggle('Simulator.add_command');">-</a><tt class="py-line">    <tt class="py-keyword">def</tt> <a class="py-def-name" href="modbus_tk.simulator.Simulator-class.html#add_command">add_command</a><tt class="py-op">(</tt><tt class="py-param">self</tt><tt class="py-op">,</tt> <tt class="py-param">name</tt><tt class="py-op">,</tt> <tt class="py-param">fct</tt><tt class="py-op">)</tt><tt class="py-op">:</tt> </tt>
</div><div id="Simulator.add_command-collapsed" style="display:none;" pad="+++" indent="++++++++"></div><div id="Simulator.add_command-expanded"><a name="L185"></a><tt class="py-lineno">185</tt>  <tt class="py-line">        <tt class="py-docstring">"""add a custom command"""</tt> </tt>
<a name="L186"></a><tt class="py-lineno">186</tt>  <tt class="py-line">        <tt class="py-name">self</tt><tt class="py-op">.</tt><tt class="py-name">cmds</tt><tt class="py-op">[</tt><tt class="py-name">name</tt><tt class="py-op">]</tt> <tt class="py-op">=</tt> <tt class="py-name">fct</tt> </tt>
</div><a name="L187"></a><tt class="py-lineno">187</tt>  <tt class="py-line">         </tt>
<a name="Simulator.start"></a><div id="Simulator.start-def"><a name="L188"></a><tt class="py-lineno">188</tt> <a class="py-toggle" href="#" id="Simulator.start-toggle" onclick="return toggle('Simulator.start');">-</a><tt class="py-line">    <tt class="py-keyword">def</tt> <a class="py-def-name" href="modbus_tk.simulator.Simulator-class.html#start">start</a><tt class="py-op">(</tt><tt class="py-param">self</tt><tt class="py-op">)</tt><tt class="py-op">:</tt> </tt>
</div><div id="Simulator.start-collapsed" style="display:none;" pad="+++" indent="++++++++"></div><div id="Simulator.start-expanded"><a name="L189"></a><tt class="py-lineno">189</tt>  <tt class="py-line">        <tt class="py-docstring">"""run the servers"""</tt> </tt>
<a name="L190"></a><tt class="py-lineno">190</tt>  <tt class="py-line">        <tt class="py-name">self</tt><tt class="py-op">.</tt><tt class="py-name">server</tt><tt class="py-op">.</tt><tt id="link-61" class="py-name"><a title="modbus_tk.modbus.Server.start
modbus_tk.simulator.CompositeServer.start
modbus_tk.simulator.Simulator.start
modbus_tk.utils.WorkerThread.start" class="py-name" href="#" onclick="return doclink('link-61', 'start', 'link-29');">start</a></tt><tt class="py-op">(</tt><tt class="py-op">)</tt> </tt>
<a name="L191"></a><tt class="py-lineno">191</tt>  <tt class="py-line">        <tt class="py-name">self</tt><tt class="py-op">.</tt><tt class="py-name">console</tt><tt class="py-op">.</tt><tt id="link-62" class="py-name"><a title="modbus_tk.modbus.Server.start
modbus_tk.simulator.CompositeServer.start
modbus_tk.simulator.Simulator.start
modbus_tk.utils.WorkerThread.start" class="py-name" href="#" onclick="return doclink('link-62', 'start', 'link-29');">start</a></tt><tt class="py-op">(</tt><tt class="py-op">)</tt> </tt>
<a name="L192"></a><tt class="py-lineno">192</tt>  <tt class="py-line">        <tt class="py-name">self</tt><tt class="py-op">.</tt><tt class="py-name">rpc</tt><tt class="py-op">.</tt><tt id="link-63" class="py-name"><a title="modbus_tk.modbus.Server.start
modbus_tk.simulator.CompositeServer.start
modbus_tk.simulator.Simulator.start
modbus_tk.utils.WorkerThread.start" class="py-name" href="#" onclick="return doclink('link-63', 'start', 'link-29');">start</a></tt><tt class="py-op">(</tt><tt class="py-op">)</tt> </tt>
<a name="L193"></a><tt class="py-lineno">193</tt>  <tt class="py-line">         </tt>
<a name="L194"></a><tt class="py-lineno">194</tt>  <tt class="py-line">        <tt id="link-64" class="py-name"><a title="modbus_tk.modbus.LOGGER
modbus_tk.modbus_rtu.LOGGER
modbus_tk.modbus_tcp.LOGGER
modbus_tk.simulator.LOGGER" class="py-name" href="#" onclick="return doclink('link-64', 'LOGGER', 'link-16');">LOGGER</a></tt><tt class="py-op">.</tt><tt class="py-name">info</tt><tt class="py-op">(</tt><tt class="py-string">"modbus_tk.simulator is running..."</tt><tt class="py-op">)</tt> </tt>
<a name="L195"></a><tt class="py-lineno">195</tt>  <tt class="py-line">         </tt>
<a name="L196"></a><tt class="py-lineno">196</tt>  <tt class="py-line">        <tt class="py-name">self</tt><tt class="py-op">.</tt><tt id="link-65" class="py-name" targets="Method modbus_tk.modbus.Server._handle()=modbus_tk.modbus.Server-class.html#_handle,Method modbus_tk.simulator.Simulator._handle()=modbus_tk.simulator.Simulator-class.html#_handle"><a title="modbus_tk.modbus.Server._handle
modbus_tk.simulator.Simulator._handle" class="py-name" href="#" onclick="return doclink('link-65', '_handle', 'link-65');">_handle</a></tt><tt class="py-op">(</tt><tt class="py-op">)</tt> </tt>
</div><a name="L197"></a><tt class="py-lineno">197</tt>  <tt class="py-line"> </tt>
<a name="Simulator.declare_hook"></a><div id="Simulator.declare_hook-def"><a name="L198"></a><tt class="py-lineno">198</tt> <a class="py-toggle" href="#" id="Simulator.declare_hook-toggle" onclick="return toggle('Simulator.declare_hook');">-</a><tt class="py-line">    <tt class="py-keyword">def</tt> <a class="py-def-name" href="modbus_tk.simulator.Simulator-class.html#declare_hook">declare_hook</a><tt class="py-op">(</tt><tt class="py-param">self</tt><tt class="py-op">,</tt> <tt class="py-param">fct_name</tt><tt class="py-op">,</tt> <tt class="py-param">fct</tt><tt class="py-op">)</tt><tt class="py-op">:</tt> </tt>
</div><div id="Simulator.declare_hook-collapsed" style="display:none;" pad="+++" indent="++++++++"></div><div id="Simulator.declare_hook-expanded"><a name="L199"></a><tt class="py-lineno">199</tt>  <tt class="py-line">        <tt class="py-docstring">"""declare a hook function by its name. It must be installed by an install hook command"""</tt> </tt>
<a name="L200"></a><tt class="py-lineno">200</tt>  <tt class="py-line">        <tt class="py-name">self</tt><tt class="py-op">.</tt><tt class="py-name">_hooks_fct</tt><tt class="py-op">[</tt><tt class="py-name">fct_name</tt><tt class="py-op">]</tt> <tt class="py-op">=</tt> <tt class="py-name">fct</tt> </tt>
</div><a name="L201"></a><tt class="py-lineno">201</tt>  <tt class="py-line">     </tt>
<a name="Simulator._tuple_to_str"></a><div id="Simulator._tuple_to_str-def"><a name="L202"></a><tt class="py-lineno">202</tt> <a class="py-toggle" href="#" id="Simulator._tuple_to_str-toggle" onclick="return toggle('Simulator._tuple_to_str');">-</a><tt class="py-line">    <tt class="py-keyword">def</tt> <a class="py-def-name" href="modbus_tk.simulator.Simulator-class.html#_tuple_to_str">_tuple_to_str</a><tt class="py-op">(</tt><tt class="py-param">self</tt><tt class="py-op">,</tt> <tt class="py-param">the_tuple</tt><tt class="py-op">)</tt><tt class="py-op">:</tt> </tt>
</div><div id="Simulator._tuple_to_str-collapsed" style="display:none;" pad="+++" indent="++++++++"></div><div id="Simulator._tuple_to_str-expanded"><a name="L203"></a><tt class="py-lineno">203</tt>  <tt class="py-line">        <tt class="py-docstring">"""convert a tuple to a string"""</tt> </tt>
<a name="L204"></a><tt class="py-lineno">204</tt>  <tt class="py-line">        <tt class="py-name">ret</tt> <tt class="py-op">=</tt> <tt class="py-string">""</tt> </tt>
<a name="L205"></a><tt class="py-lineno">205</tt>  <tt class="py-line">        <tt class="py-keyword">for</tt> <tt class="py-name">item</tt> <tt class="py-keyword">in</tt> <tt class="py-name">the_tuple</tt><tt class="py-op">:</tt> </tt>
<a name="L206"></a><tt class="py-lineno">206</tt>  <tt class="py-line">            <tt class="py-name">ret</tt> <tt class="py-op">+=</tt> <tt class="py-op">(</tt><tt class="py-string">" "</tt> <tt class="py-op">+</tt> <tt class="py-name">str</tt><tt class="py-op">(</tt><tt class="py-name">item</tt><tt class="py-op">)</tt><tt class="py-op">)</tt> </tt>
<a name="L207"></a><tt class="py-lineno">207</tt>  <tt class="py-line">        <tt class="py-keyword">return</tt> <tt class="py-name">ret</tt><tt class="py-op">[</tt><tt class="py-number">1</tt><tt class="py-op">:</tt><tt class="py-op">]</tt> </tt>
</div><a name="L208"></a><tt class="py-lineno">208</tt>  <tt class="py-line">     </tt>
<a name="Simulator._do_add_slave"></a><div id="Simulator._do_add_slave-def"><a name="L209"></a><tt class="py-lineno">209</tt> <a class="py-toggle" href="#" id="Simulator._do_add_slave-toggle" onclick="return toggle('Simulator._do_add_slave');">-</a><tt class="py-line">    <tt class="py-keyword">def</tt> <a class="py-def-name" href="modbus_tk.simulator.Simulator-class.html#_do_add_slave">_do_add_slave</a><tt class="py-op">(</tt><tt class="py-param">self</tt><tt class="py-op">,</tt> <tt class="py-param">args</tt><tt class="py-op">)</tt><tt class="py-op">:</tt> </tt>
</div><div id="Simulator._do_add_slave-collapsed" style="display:none;" pad="+++" indent="++++++++"></div><div id="Simulator._do_add_slave-expanded"><a name="L210"></a><tt class="py-lineno">210</tt>  <tt class="py-line">        <tt class="py-docstring">"""execute the add_slave command"""</tt> </tt>
<a name="L211"></a><tt class="py-lineno">211</tt>  <tt class="py-line">        <tt class="py-name">slave_id</tt> <tt class="py-op">=</tt> <tt class="py-name">int</tt><tt class="py-op">(</tt><tt class="py-name">args</tt><tt class="py-op">[</tt><tt class="py-number">1</tt><tt class="py-op">]</tt><tt class="py-op">)</tt> </tt>
<a name="L212"></a><tt class="py-lineno">212</tt>  <tt class="py-line">        <tt class="py-name">self</tt><tt class="py-op">.</tt><tt class="py-name">server</tt><tt class="py-op">.</tt><tt id="link-66" class="py-name" targets="Method modbus_tk.modbus.Databank.add_slave()=modbus_tk.modbus.Databank-class.html#add_slave,Method modbus_tk.modbus.Server.add_slave()=modbus_tk.modbus.Server-class.html#add_slave,Method modbus_tk.simulator_rpc_client.SimulatorRpcClient.add_slave()=modbus_tk.simulator_rpc_client.SimulatorRpcClient-class.html#add_slave"><a title="modbus_tk.modbus.Databank.add_slave
modbus_tk.modbus.Server.add_slave
modbus_tk.simulator_rpc_client.SimulatorRpcClient.add_slave" class="py-name" href="#" onclick="return doclink('link-66', 'add_slave', 'link-66');">add_slave</a></tt><tt class="py-op">(</tt><tt class="py-name">slave_id</tt><tt class="py-op">)</tt> </tt>
<a name="L213"></a><tt class="py-lineno">213</tt>  <tt class="py-line">        <tt class="py-keyword">return</tt> <tt class="py-string">"%d"</tt> <tt class="py-op">%</tt> <tt class="py-op">(</tt><tt class="py-name">slave_id</tt><tt class="py-op">)</tt> </tt>
</div><a name="L214"></a><tt class="py-lineno">214</tt>  <tt class="py-line">     </tt>
<a name="Simulator._do_has_slave"></a><div id="Simulator._do_has_slave-def"><a name="L215"></a><tt class="py-lineno">215</tt> <a class="py-toggle" href="#" id="Simulator._do_has_slave-toggle" onclick="return toggle('Simulator._do_has_slave');">-</a><tt class="py-line">    <tt class="py-keyword">def</tt> <a class="py-def-name" href="modbus_tk.simulator.Simulator-class.html#_do_has_slave">_do_has_slave</a><tt class="py-op">(</tt><tt class="py-param">self</tt><tt class="py-op">,</tt> <tt class="py-param">args</tt><tt class="py-op">)</tt><tt class="py-op">:</tt> </tt>
</div><div id="Simulator._do_has_slave-collapsed" style="display:none;" pad="+++" indent="++++++++"></div><div id="Simulator._do_has_slave-expanded"><a name="L216"></a><tt class="py-lineno">216</tt>  <tt class="py-line">        <tt class="py-docstring">"""execute the has_slave command"""</tt> </tt>
<a name="L217"></a><tt class="py-lineno">217</tt>  <tt class="py-line">        <tt class="py-name">slave_id</tt> <tt class="py-op">=</tt> <tt class="py-name">int</tt><tt class="py-op">(</tt><tt class="py-name">args</tt><tt class="py-op">[</tt><tt class="py-number">1</tt><tt class="py-op">]</tt><tt class="py-op">)</tt> </tt>
<a name="L218"></a><tt class="py-lineno">218</tt>  <tt class="py-line">        <tt class="py-keyword">try</tt><tt class="py-op">:</tt> </tt>
<a name="L219"></a><tt class="py-lineno">219</tt>  <tt class="py-line">            <tt class="py-name">self</tt><tt class="py-op">.</tt><tt class="py-name">server</tt><tt class="py-op">.</tt><tt id="link-67" class="py-name" targets="Method modbus_tk.modbus.Databank.get_slave()=modbus_tk.modbus.Databank-class.html#get_slave,Method modbus_tk.modbus.Server.get_slave()=modbus_tk.modbus.Server-class.html#get_slave"><a title="modbus_tk.modbus.Databank.get_slave
modbus_tk.modbus.Server.get_slave" class="py-name" href="#" onclick="return doclink('link-67', 'get_slave', 'link-67');">get_slave</a></tt><tt class="py-op">(</tt><tt class="py-name">slave_id</tt><tt class="py-op">)</tt> </tt>
<a name="L220"></a><tt class="py-lineno">220</tt>  <tt class="py-line">        <tt class="py-keyword">except</tt><tt class="py-op">:</tt> </tt>
<a name="L221"></a><tt class="py-lineno">221</tt>  <tt class="py-line">            <tt class="py-keyword">return</tt> <tt class="py-string">"0"</tt> </tt>
<a name="L222"></a><tt class="py-lineno">222</tt>  <tt class="py-line">        <tt class="py-keyword">return</tt> <tt class="py-string">"1"</tt> </tt>
</div><a name="L223"></a><tt class="py-lineno">223</tt>  <tt class="py-line">         </tt>
<a name="Simulator._do_remove_slave"></a><div id="Simulator._do_remove_slave-def"><a name="L224"></a><tt class="py-lineno">224</tt> <a class="py-toggle" href="#" id="Simulator._do_remove_slave-toggle" onclick="return toggle('Simulator._do_remove_slave');">-</a><tt class="py-line">    <tt class="py-keyword">def</tt> <a class="py-def-name" href="modbus_tk.simulator.Simulator-class.html#_do_remove_slave">_do_remove_slave</a><tt class="py-op">(</tt><tt class="py-param">self</tt><tt class="py-op">,</tt> <tt class="py-param">args</tt><tt class="py-op">)</tt><tt class="py-op">:</tt> </tt>
</div><div id="Simulator._do_remove_slave-collapsed" style="display:none;" pad="+++" indent="++++++++"></div><div id="Simulator._do_remove_slave-expanded"><a name="L225"></a><tt class="py-lineno">225</tt>  <tt class="py-line">        <tt class="py-docstring">"""execute the remove_slave command"""</tt> </tt>
<a name="L226"></a><tt class="py-lineno">226</tt>  <tt class="py-line">        <tt class="py-name">slave_id</tt> <tt class="py-op">=</tt> <tt class="py-name">int</tt><tt class="py-op">(</tt><tt class="py-name">args</tt><tt class="py-op">[</tt><tt class="py-number">1</tt><tt class="py-op">]</tt><tt class="py-op">)</tt> </tt>
<a name="L227"></a><tt class="py-lineno">227</tt>  <tt class="py-line">        <tt class="py-name">self</tt><tt class="py-op">.</tt><tt class="py-name">server</tt><tt class="py-op">.</tt><tt id="link-68" class="py-name" targets="Method modbus_tk.modbus.Databank.remove_slave()=modbus_tk.modbus.Databank-class.html#remove_slave,Method modbus_tk.modbus.Server.remove_slave()=modbus_tk.modbus.Server-class.html#remove_slave,Method modbus_tk.simulator_rpc_client.SimulatorRpcClient.remove_slave()=modbus_tk.simulator_rpc_client.SimulatorRpcClient-class.html#remove_slave"><a title="modbus_tk.modbus.Databank.remove_slave
modbus_tk.modbus.Server.remove_slave
modbus_tk.simulator_rpc_client.SimulatorRpcClient.remove_slave" class="py-name" href="#" onclick="return doclink('link-68', 'remove_slave', 'link-68');">remove_slave</a></tt><tt class="py-op">(</tt><tt class="py-name">slave_id</tt><tt class="py-op">)</tt> </tt>
<a name="L228"></a><tt class="py-lineno">228</tt>  <tt class="py-line">        <tt class="py-keyword">return</tt> <tt class="py-string">""</tt> </tt>
</div><a name="L229"></a><tt class="py-lineno">229</tt>  <tt class="py-line"> </tt>
<a name="Simulator._do_remove_all_slaves"></a><div id="Simulator._do_remove_all_slaves-def"><a name="L230"></a><tt class="py-lineno">230</tt> <a class="py-toggle" href="#" id="Simulator._do_remove_all_slaves-toggle" onclick="return toggle('Simulator._do_remove_all_slaves');">-</a><tt class="py-line">    <tt class="py-keyword">def</tt> <a class="py-def-name" href="modbus_tk.simulator.Simulator-class.html#_do_remove_all_slaves">_do_remove_all_slaves</a><tt class="py-op">(</tt><tt class="py-param">self</tt><tt class="py-op">,</tt> <tt class="py-param">args</tt><tt class="py-op">)</tt><tt class="py-op">:</tt> </tt>
</div><div id="Simulator._do_remove_all_slaves-collapsed" style="display:none;" pad="+++" indent="++++++++"></div><div id="Simulator._do_remove_all_slaves-expanded"><a name="L231"></a><tt class="py-lineno">231</tt>  <tt class="py-line">        <tt class="py-docstring">"""execute the remove_slave command"""</tt> </tt>
<a name="L232"></a><tt class="py-lineno">232</tt>  <tt class="py-line">        <tt class="py-name">self</tt><tt class="py-op">.</tt><tt class="py-name">server</tt><tt class="py-op">.</tt><tt id="link-69" class="py-name" targets="Method modbus_tk.modbus.Databank.remove_all_slaves()=modbus_tk.modbus.Databank-class.html#remove_all_slaves,Method modbus_tk.modbus.Server.remove_all_slaves()=modbus_tk.modbus.Server-class.html#remove_all_slaves,Method modbus_tk.simulator_rpc_client.SimulatorRpcClient.remove_all_slaves()=modbus_tk.simulator_rpc_client.SimulatorRpcClient-class.html#remove_all_slaves"><a title="modbus_tk.modbus.Databank.remove_all_slaves
modbus_tk.modbus.Server.remove_all_slaves
modbus_tk.simulator_rpc_client.SimulatorRpcClient.remove_all_slaves" class="py-name" href="#" onclick="return doclink('link-69', 'remove_all_slaves', 'link-69');">remove_all_slaves</a></tt><tt class="py-op">(</tt><tt class="py-op">)</tt> </tt>
<a name="L233"></a><tt class="py-lineno">233</tt>  <tt class="py-line">        <tt class="py-keyword">return</tt> <tt class="py-string">""</tt> </tt>
</div><a name="L234"></a><tt class="py-lineno">234</tt>  <tt class="py-line"> </tt>
<a name="Simulator._do_add_slave"></a><div id="Simulator._do_add_slave-def"><a name="L235"></a><tt class="py-lineno">235</tt> <a class="py-toggle" href="#" id="Simulator._do_add_slave-toggle" onclick="return toggle('Simulator._do_add_slave');">-</a><tt class="py-line">    <tt class="py-keyword">def</tt> <a class="py-def-name" href="modbus_tk.simulator.Simulator-class.html#_do_add_slave">_do_add_slave</a><tt class="py-op">(</tt><tt class="py-param">self</tt><tt class="py-op">,</tt> <tt class="py-param">args</tt><tt class="py-op">)</tt><tt class="py-op">:</tt> </tt>
</div><div id="Simulator._do_add_slave-collapsed" style="display:none;" pad="+++" indent="++++++++"></div><div id="Simulator._do_add_slave-expanded"><a name="L236"></a><tt class="py-lineno">236</tt>  <tt class="py-line">        <tt class="py-docstring">"""execute the add_slave command"""</tt> </tt>
<a name="L237"></a><tt class="py-lineno">237</tt>  <tt class="py-line">        <tt class="py-name">slave_id</tt> <tt class="py-op">=</tt> <tt class="py-name">int</tt><tt class="py-op">(</tt><tt class="py-name">args</tt><tt class="py-op">[</tt><tt class="py-number">1</tt><tt class="py-op">]</tt><tt class="py-op">)</tt> </tt>
<a name="L238"></a><tt class="py-lineno">238</tt>  <tt class="py-line">        <tt class="py-name">self</tt><tt class="py-op">.</tt><tt class="py-name">server</tt><tt class="py-op">.</tt><tt id="link-70" class="py-name"><a title="modbus_tk.modbus.Databank.add_slave
modbus_tk.modbus.Server.add_slave
modbus_tk.simulator_rpc_client.SimulatorRpcClient.add_slave" class="py-name" href="#" onclick="return doclink('link-70', 'add_slave', 'link-66');">add_slave</a></tt><tt class="py-op">(</tt><tt class="py-name">slave_id</tt><tt class="py-op">)</tt> </tt>
<a name="L239"></a><tt class="py-lineno">239</tt>  <tt class="py-line">        <tt class="py-keyword">return</tt> <tt class="py-string">"%d"</tt> <tt class="py-op">%</tt> <tt class="py-op">(</tt><tt class="py-name">slave_id</tt><tt class="py-op">)</tt> </tt>
</div><a name="L240"></a><tt class="py-lineno">240</tt>  <tt class="py-line"> </tt>
<a name="Simulator._do_add_block"></a><div id="Simulator._do_add_block-def"><a name="L241"></a><tt class="py-lineno">241</tt> <a class="py-toggle" href="#" id="Simulator._do_add_block-toggle" onclick="return toggle('Simulator._do_add_block');">-</a><tt class="py-line">    <tt class="py-keyword">def</tt> <a class="py-def-name" href="modbus_tk.simulator.Simulator-class.html#_do_add_block">_do_add_block</a><tt class="py-op">(</tt><tt class="py-param">self</tt><tt class="py-op">,</tt> <tt class="py-param">args</tt><tt class="py-op">)</tt><tt class="py-op">:</tt> </tt>
</div><div id="Simulator._do_add_block-collapsed" style="display:none;" pad="+++" indent="++++++++"></div><div id="Simulator._do_add_block-expanded"><a name="L242"></a><tt class="py-lineno">242</tt>  <tt class="py-line">        <tt class="py-docstring">"""execute the add_block command"""</tt> </tt>
<a name="L243"></a><tt class="py-lineno">243</tt>  <tt class="py-line">        <tt class="py-name">slave_id</tt> <tt class="py-op">=</tt> <tt class="py-name">int</tt><tt class="py-op">(</tt><tt class="py-name">args</tt><tt class="py-op">[</tt><tt class="py-number">1</tt><tt class="py-op">]</tt><tt class="py-op">)</tt> </tt>
<a name="L244"></a><tt class="py-lineno">244</tt>  <tt class="py-line">        <tt class="py-name">name</tt> <tt class="py-op">=</tt> <tt class="py-name">args</tt><tt class="py-op">[</tt><tt class="py-number">2</tt><tt class="py-op">]</tt> </tt>
<a name="L245"></a><tt class="py-lineno">245</tt>  <tt class="py-line">        <tt class="py-name">block_type</tt> <tt class="py-op">=</tt> <tt class="py-name">int</tt><tt class="py-op">(</tt><tt class="py-name">args</tt><tt class="py-op">[</tt><tt class="py-number">3</tt><tt class="py-op">]</tt><tt class="py-op">)</tt> </tt>
<a name="L246"></a><tt class="py-lineno">246</tt>  <tt class="py-line">        <tt class="py-name">starting_address</tt> <tt class="py-op">=</tt> <tt class="py-name">int</tt><tt class="py-op">(</tt><tt class="py-name">args</tt><tt class="py-op">[</tt><tt class="py-number">4</tt><tt class="py-op">]</tt><tt class="py-op">)</tt> </tt>
<a name="L247"></a><tt class="py-lineno">247</tt>  <tt class="py-line">        <tt class="py-name">length</tt> <tt class="py-op">=</tt> <tt class="py-name">int</tt><tt class="py-op">(</tt><tt class="py-name">args</tt><tt class="py-op">[</tt><tt class="py-number">5</tt><tt class="py-op">]</tt><tt class="py-op">)</tt> </tt>
<a name="L248"></a><tt class="py-lineno">248</tt>  <tt class="py-line">        <tt class="py-name">slave</tt> <tt class="py-op">=</tt> <tt class="py-name">self</tt><tt class="py-op">.</tt><tt class="py-name">server</tt><tt class="py-op">.</tt><tt id="link-71" class="py-name"><a title="modbus_tk.modbus.Databank.get_slave
modbus_tk.modbus.Server.get_slave" class="py-name" href="#" onclick="return doclink('link-71', 'get_slave', 'link-67');">get_slave</a></tt><tt class="py-op">(</tt><tt class="py-name">slave_id</tt><tt class="py-op">)</tt> </tt>
<a name="L249"></a><tt class="py-lineno">249</tt>  <tt class="py-line">        <tt class="py-name">slave</tt><tt class="py-op">.</tt><tt id="link-72" class="py-name" targets="Method modbus_tk.modbus.Slave.add_block()=modbus_tk.modbus.Slave-class.html#add_block,Method modbus_tk.simulator_rpc_client.SimulatorRpcClient.add_block()=modbus_tk.simulator_rpc_client.SimulatorRpcClient-class.html#add_block"><a title="modbus_tk.modbus.Slave.add_block
modbus_tk.simulator_rpc_client.SimulatorRpcClient.add_block" class="py-name" href="#" onclick="return doclink('link-72', 'add_block', 'link-72');">add_block</a></tt><tt class="py-op">(</tt><tt class="py-name">name</tt><tt class="py-op">,</tt> <tt class="py-name">block_type</tt><tt class="py-op">,</tt> <tt class="py-name">starting_address</tt><tt class="py-op">,</tt> <tt class="py-name">length</tt><tt class="py-op">)</tt> </tt>
<a name="L250"></a><tt class="py-lineno">250</tt>  <tt class="py-line">        <tt class="py-keyword">return</tt> <tt class="py-name">name</tt> </tt>
</div><a name="L251"></a><tt class="py-lineno">251</tt>  <tt class="py-line"> </tt>
<a name="Simulator._do_remove_block"></a><div id="Simulator._do_remove_block-def"><a name="L252"></a><tt class="py-lineno">252</tt> <a class="py-toggle" href="#" id="Simulator._do_remove_block-toggle" onclick="return toggle('Simulator._do_remove_block');">-</a><tt class="py-line">    <tt class="py-keyword">def</tt> <a class="py-def-name" href="modbus_tk.simulator.Simulator-class.html#_do_remove_block">_do_remove_block</a><tt class="py-op">(</tt><tt class="py-param">self</tt><tt class="py-op">,</tt> <tt class="py-param">args</tt><tt class="py-op">)</tt><tt class="py-op">:</tt> </tt>
</div><div id="Simulator._do_remove_block-collapsed" style="display:none;" pad="+++" indent="++++++++"></div><div id="Simulator._do_remove_block-expanded"><a name="L253"></a><tt class="py-lineno">253</tt>  <tt class="py-line">        <tt class="py-docstring">"""execute the remove_block command"""</tt> </tt>
<a name="L254"></a><tt class="py-lineno">254</tt>  <tt class="py-line">        <tt class="py-name">slave_id</tt> <tt class="py-op">=</tt> <tt class="py-name">int</tt><tt class="py-op">(</tt><tt class="py-name">args</tt><tt class="py-op">[</tt><tt class="py-number">1</tt><tt class="py-op">]</tt><tt class="py-op">)</tt> </tt>
<a name="L255"></a><tt class="py-lineno">255</tt>  <tt class="py-line">        <tt class="py-name">name</tt> <tt class="py-op">=</tt> <tt class="py-name">args</tt><tt class="py-op">[</tt><tt class="py-number">2</tt><tt class="py-op">]</tt> </tt>
<a name="L256"></a><tt class="py-lineno">256</tt>  <tt class="py-line">        <tt class="py-name">slave</tt> <tt class="py-op">=</tt> <tt class="py-name">self</tt><tt class="py-op">.</tt><tt class="py-name">server</tt><tt class="py-op">.</tt><tt id="link-73" class="py-name"><a title="modbus_tk.modbus.Databank.get_slave
modbus_tk.modbus.Server.get_slave" class="py-name" href="#" onclick="return doclink('link-73', 'get_slave', 'link-67');">get_slave</a></tt><tt class="py-op">(</tt><tt class="py-name">slave_id</tt><tt class="py-op">)</tt> </tt>
<a name="L257"></a><tt class="py-lineno">257</tt>  <tt class="py-line">        <tt class="py-name">slave</tt><tt class="py-op">.</tt><tt id="link-74" class="py-name" targets="Method modbus_tk.modbus.Slave.remove_block()=modbus_tk.modbus.Slave-class.html#remove_block,Method modbus_tk.simulator_rpc_client.SimulatorRpcClient.remove_block()=modbus_tk.simulator_rpc_client.SimulatorRpcClient-class.html#remove_block"><a title="modbus_tk.modbus.Slave.remove_block
modbus_tk.simulator_rpc_client.SimulatorRpcClient.remove_block" class="py-name" href="#" onclick="return doclink('link-74', 'remove_block', 'link-74');">remove_block</a></tt><tt class="py-op">(</tt><tt class="py-name">name</tt><tt class="py-op">)</tt> </tt>
</div><a name="L258"></a><tt class="py-lineno">258</tt>  <tt class="py-line"> </tt>
<a name="Simulator._do_remove_all_blocks"></a><div id="Simulator._do_remove_all_blocks-def"><a name="L259"></a><tt class="py-lineno">259</tt> <a class="py-toggle" href="#" id="Simulator._do_remove_all_blocks-toggle" onclick="return toggle('Simulator._do_remove_all_blocks');">-</a><tt class="py-line">    <tt class="py-keyword">def</tt> <a class="py-def-name" href="modbus_tk.simulator.Simulator-class.html#_do_remove_all_blocks">_do_remove_all_blocks</a><tt class="py-op">(</tt><tt class="py-param">self</tt><tt class="py-op">,</tt> <tt class="py-param">args</tt><tt class="py-op">)</tt><tt class="py-op">:</tt> </tt>
</div><div id="Simulator._do_remove_all_blocks-collapsed" style="display:none;" pad="+++" indent="++++++++"></div><div id="Simulator._do_remove_all_blocks-expanded"><a name="L260"></a><tt class="py-lineno">260</tt>  <tt class="py-line">        <tt class="py-docstring">"""execute the remove_all_blocks command"""</tt> </tt>
<a name="L261"></a><tt class="py-lineno">261</tt>  <tt class="py-line">        <tt class="py-name">slave_id</tt> <tt class="py-op">=</tt> <tt class="py-name">int</tt><tt class="py-op">(</tt><tt class="py-name">args</tt><tt class="py-op">[</tt><tt class="py-number">1</tt><tt class="py-op">]</tt><tt class="py-op">)</tt> </tt>
<a name="L262"></a><tt class="py-lineno">262</tt>  <tt class="py-line">        <tt class="py-name">slave</tt> <tt class="py-op">=</tt> <tt class="py-name">self</tt><tt class="py-op">.</tt><tt class="py-name">server</tt><tt class="py-op">.</tt><tt id="link-75" class="py-name"><a title="modbus_tk.modbus.Databank.get_slave
modbus_tk.modbus.Server.get_slave" class="py-name" href="#" onclick="return doclink('link-75', 'get_slave', 'link-67');">get_slave</a></tt><tt class="py-op">(</tt><tt class="py-name">slave_id</tt><tt class="py-op">)</tt> </tt>
<a name="L263"></a><tt class="py-lineno">263</tt>  <tt class="py-line">        <tt class="py-name">slave</tt><tt class="py-op">.</tt><tt id="link-76" class="py-name" targets="Method modbus_tk.modbus.Slave.remove_all_blocks()=modbus_tk.modbus.Slave-class.html#remove_all_blocks,Method modbus_tk.simulator_rpc_client.SimulatorRpcClient.remove_all_blocks()=modbus_tk.simulator_rpc_client.SimulatorRpcClient-class.html#remove_all_blocks"><a title="modbus_tk.modbus.Slave.remove_all_blocks
modbus_tk.simulator_rpc_client.SimulatorRpcClient.remove_all_blocks" class="py-name" href="#" onclick="return doclink('link-76', 'remove_all_blocks', 'link-76');">remove_all_blocks</a></tt><tt class="py-op">(</tt><tt class="py-op">)</tt> </tt>
</div><a name="L264"></a><tt class="py-lineno">264</tt>  <tt class="py-line">         </tt>
<a name="Simulator._do_set_values"></a><div id="Simulator._do_set_values-def"><a name="L265"></a><tt class="py-lineno">265</tt> <a class="py-toggle" href="#" id="Simulator._do_set_values-toggle" onclick="return toggle('Simulator._do_set_values');">-</a><tt class="py-line">    <tt class="py-keyword">def</tt> <a class="py-def-name" href="modbus_tk.simulator.Simulator-class.html#_do_set_values">_do_set_values</a><tt class="py-op">(</tt><tt class="py-param">self</tt><tt class="py-op">,</tt> <tt class="py-param">args</tt><tt class="py-op">)</tt><tt class="py-op">:</tt> </tt>
</div><div id="Simulator._do_set_values-collapsed" style="display:none;" pad="+++" indent="++++++++"></div><div id="Simulator._do_set_values-expanded"><a name="L266"></a><tt class="py-lineno">266</tt>  <tt class="py-line">        <tt class="py-docstring">"""execute the set_values command"""</tt> </tt>
<a name="L267"></a><tt class="py-lineno">267</tt>  <tt class="py-line">        <tt class="py-name">slave_id</tt> <tt class="py-op">=</tt> <tt class="py-name">int</tt><tt class="py-op">(</tt><tt class="py-name">args</tt><tt class="py-op">[</tt><tt class="py-number">1</tt><tt class="py-op">]</tt><tt class="py-op">)</tt> </tt>
<a name="L268"></a><tt class="py-lineno">268</tt>  <tt class="py-line">        <tt class="py-name">name</tt> <tt class="py-op">=</tt> <tt class="py-name">args</tt><tt class="py-op">[</tt><tt class="py-number">2</tt><tt class="py-op">]</tt> </tt>
<a name="L269"></a><tt class="py-lineno">269</tt>  <tt class="py-line">        <tt class="py-name">address</tt> <tt class="py-op">=</tt> <tt class="py-name">int</tt><tt class="py-op">(</tt><tt class="py-name">args</tt><tt class="py-op">[</tt><tt class="py-number">3</tt><tt class="py-op">]</tt><tt class="py-op">)</tt> </tt>
<a name="L270"></a><tt class="py-lineno">270</tt>  <tt class="py-line">        <tt class="py-name">values</tt> <tt class="py-op">=</tt> <tt class="py-op">[</tt><tt class="py-op">]</tt> </tt>
<a name="L271"></a><tt class="py-lineno">271</tt>  <tt class="py-line">        <tt class="py-keyword">for</tt> <tt class="py-name">val</tt> <tt class="py-keyword">in</tt> <tt class="py-name">args</tt><tt class="py-op">[</tt><tt class="py-number">4</tt><tt class="py-op">:</tt><tt class="py-op">]</tt><tt class="py-op">:</tt> </tt>
<a name="L272"></a><tt class="py-lineno">272</tt>  <tt class="py-line">            <tt class="py-name">values</tt><tt class="py-op">.</tt><tt class="py-name">append</tt><tt class="py-op">(</tt><tt class="py-name">int</tt><tt class="py-op">(</tt><tt class="py-name">val</tt><tt class="py-op">)</tt><tt class="py-op">)</tt> </tt>
<a name="L273"></a><tt class="py-lineno">273</tt>  <tt class="py-line">        <tt class="py-name">slave</tt> <tt class="py-op">=</tt> <tt class="py-name">self</tt><tt class="py-op">.</tt><tt class="py-name">server</tt><tt class="py-op">.</tt><tt id="link-77" class="py-name"><a title="modbus_tk.modbus.Databank.get_slave
modbus_tk.modbus.Server.get_slave" class="py-name" href="#" onclick="return doclink('link-77', 'get_slave', 'link-67');">get_slave</a></tt><tt class="py-op">(</tt><tt class="py-name">slave_id</tt><tt class="py-op">)</tt> </tt>
<a name="L274"></a><tt class="py-lineno">274</tt>  <tt class="py-line">        <tt class="py-name">slave</tt><tt class="py-op">.</tt><tt id="link-78" class="py-name" targets="Method modbus_tk.modbus.Slave.set_values()=modbus_tk.modbus.Slave-class.html#set_values,Method modbus_tk.simulator_rpc_client.SimulatorRpcClient.set_values()=modbus_tk.simulator_rpc_client.SimulatorRpcClient-class.html#set_values"><a title="modbus_tk.modbus.Slave.set_values
modbus_tk.simulator_rpc_client.SimulatorRpcClient.set_values" class="py-name" href="#" onclick="return doclink('link-78', 'set_values', 'link-78');">set_values</a></tt><tt class="py-op">(</tt><tt class="py-name">name</tt><tt class="py-op">,</tt> <tt class="py-name">address</tt><tt class="py-op">,</tt> <tt class="py-name">values</tt><tt class="py-op">)</tt> </tt>
<a name="L275"></a><tt class="py-lineno">275</tt>  <tt class="py-line">        <tt class="py-name">values</tt> <tt class="py-op">=</tt> <tt class="py-name">slave</tt><tt class="py-op">.</tt><tt id="link-79" class="py-name" targets="Method modbus_tk.modbus.Slave.get_values()=modbus_tk.modbus.Slave-class.html#get_values,Method modbus_tk.simulator_rpc_client.SimulatorRpcClient.get_values()=modbus_tk.simulator_rpc_client.SimulatorRpcClient-class.html#get_values"><a title="modbus_tk.modbus.Slave.get_values
modbus_tk.simulator_rpc_client.SimulatorRpcClient.get_values" class="py-name" href="#" onclick="return doclink('link-79', 'get_values', 'link-79');">get_values</a></tt><tt class="py-op">(</tt><tt class="py-name">name</tt><tt class="py-op">,</tt> <tt class="py-name">address</tt><tt class="py-op">,</tt> <tt class="py-name">len</tt><tt class="py-op">(</tt><tt class="py-name">values</tt><tt class="py-op">)</tt><tt class="py-op">)</tt> </tt>
<a name="L276"></a><tt class="py-lineno">276</tt>  <tt class="py-line">        <tt class="py-keyword">return</tt> <tt class="py-name">self</tt><tt class="py-op">.</tt><tt id="link-80" class="py-name" targets="Method modbus_tk.simulator.Simulator._tuple_to_str()=modbus_tk.simulator.Simulator-class.html#_tuple_to_str"><a title="modbus_tk.simulator.Simulator._tuple_to_str" class="py-name" href="#" onclick="return doclink('link-80', '_tuple_to_str', 'link-80');">_tuple_to_str</a></tt><tt class="py-op">(</tt><tt class="py-name">values</tt><tt class="py-op">)</tt> </tt>
</div><a name="L277"></a><tt class="py-lineno">277</tt>  <tt class="py-line">     </tt>
<a name="Simulator._do_get_values"></a><div id="Simulator._do_get_values-def"><a name="L278"></a><tt class="py-lineno">278</tt> <a class="py-toggle" href="#" id="Simulator._do_get_values-toggle" onclick="return toggle('Simulator._do_get_values');">-</a><tt class="py-line">    <tt class="py-keyword">def</tt> <a class="py-def-name" href="modbus_tk.simulator.Simulator-class.html#_do_get_values">_do_get_values</a><tt class="py-op">(</tt><tt class="py-param">self</tt><tt class="py-op">,</tt> <tt class="py-param">args</tt><tt class="py-op">)</tt><tt class="py-op">:</tt> </tt>
</div><div id="Simulator._do_get_values-collapsed" style="display:none;" pad="+++" indent="++++++++"></div><div id="Simulator._do_get_values-expanded"><a name="L279"></a><tt class="py-lineno">279</tt>  <tt class="py-line">        <tt class="py-docstring">"""execute the get_values command"""</tt> </tt>
<a name="L280"></a><tt class="py-lineno">280</tt>  <tt class="py-line">        <tt class="py-name">slave_id</tt> <tt class="py-op">=</tt> <tt class="py-name">int</tt><tt class="py-op">(</tt><tt class="py-name">args</tt><tt class="py-op">[</tt><tt class="py-number">1</tt><tt class="py-op">]</tt><tt class="py-op">)</tt> </tt>
<a name="L281"></a><tt class="py-lineno">281</tt>  <tt class="py-line">        <tt class="py-name">name</tt> <tt class="py-op">=</tt> <tt class="py-name">args</tt><tt class="py-op">[</tt><tt class="py-number">2</tt><tt class="py-op">]</tt> </tt>
<a name="L282"></a><tt class="py-lineno">282</tt>  <tt class="py-line">        <tt class="py-name">address</tt> <tt class="py-op">=</tt> <tt class="py-name">int</tt><tt class="py-op">(</tt><tt class="py-name">args</tt><tt class="py-op">[</tt><tt class="py-number">3</tt><tt class="py-op">]</tt><tt class="py-op">)</tt> </tt>
<a name="L283"></a><tt class="py-lineno">283</tt>  <tt class="py-line">        <tt class="py-name">length</tt> <tt class="py-op">=</tt> <tt class="py-name">int</tt><tt class="py-op">(</tt><tt class="py-name">args</tt><tt class="py-op">[</tt><tt class="py-number">4</tt><tt class="py-op">]</tt><tt class="py-op">)</tt> </tt>
<a name="L284"></a><tt class="py-lineno">284</tt>  <tt class="py-line">        <tt class="py-name">slave</tt> <tt class="py-op">=</tt> <tt class="py-name">self</tt><tt class="py-op">.</tt><tt class="py-name">server</tt><tt class="py-op">.</tt><tt id="link-81" class="py-name"><a title="modbus_tk.modbus.Databank.get_slave
modbus_tk.modbus.Server.get_slave" class="py-name" href="#" onclick="return doclink('link-81', 'get_slave', 'link-67');">get_slave</a></tt><tt class="py-op">(</tt><tt class="py-name">slave_id</tt><tt class="py-op">)</tt> </tt>
<a name="L285"></a><tt class="py-lineno">285</tt>  <tt class="py-line">        <tt class="py-name">values</tt> <tt class="py-op">=</tt> <tt class="py-name">slave</tt><tt class="py-op">.</tt><tt id="link-82" class="py-name"><a title="modbus_tk.modbus.Slave.get_values
modbus_tk.simulator_rpc_client.SimulatorRpcClient.get_values" class="py-name" href="#" onclick="return doclink('link-82', 'get_values', 'link-79');">get_values</a></tt><tt class="py-op">(</tt><tt class="py-name">name</tt><tt class="py-op">,</tt> <tt class="py-name">address</tt><tt class="py-op">,</tt> <tt class="py-name">length</tt><tt class="py-op">)</tt> </tt>
<a name="L286"></a><tt class="py-lineno">286</tt>  <tt class="py-line">        <tt class="py-keyword">return</tt> <tt class="py-name">self</tt><tt class="py-op">.</tt><tt id="link-83" class="py-name"><a title="modbus_tk.simulator.Simulator._tuple_to_str" class="py-name" href="#" onclick="return doclink('link-83', '_tuple_to_str', 'link-80');">_tuple_to_str</a></tt><tt class="py-op">(</tt><tt class="py-name">values</tt><tt class="py-op">)</tt> </tt>
</div><a name="L287"></a><tt class="py-lineno">287</tt>  <tt class="py-line"> </tt>
<a name="Simulator._do_install_hook"></a><div id="Simulator._do_install_hook-def"><a name="L288"></a><tt class="py-lineno">288</tt> <a class="py-toggle" href="#" id="Simulator._do_install_hook-toggle" onclick="return toggle('Simulator._do_install_hook');">-</a><tt class="py-line">    <tt class="py-keyword">def</tt> <a class="py-def-name" href="modbus_tk.simulator.Simulator-class.html#_do_install_hook">_do_install_hook</a><tt class="py-op">(</tt><tt class="py-param">self</tt><tt class="py-op">,</tt> <tt class="py-param">args</tt><tt class="py-op">)</tt><tt class="py-op">:</tt> </tt>
</div><div id="Simulator._do_install_hook-collapsed" style="display:none;" pad="+++" indent="++++++++"></div><div id="Simulator._do_install_hook-expanded"><a name="L289"></a><tt class="py-lineno">289</tt>  <tt class="py-line">        <tt class="py-docstring">"""install a function as a hook"""</tt> </tt>
<a name="L290"></a><tt class="py-lineno">290</tt>  <tt class="py-line">        <tt class="py-name">hook_name</tt> <tt class="py-op">=</tt> <tt class="py-name">args</tt><tt class="py-op">[</tt><tt class="py-number">1</tt><tt class="py-op">]</tt> </tt>
<a name="L291"></a><tt class="py-lineno">291</tt>  <tt class="py-line">        <tt class="py-name">fct_name</tt> <tt class="py-op">=</tt> <tt class="py-name">args</tt><tt class="py-op">[</tt><tt class="py-number">2</tt><tt class="py-op">]</tt> </tt>
<a name="L292"></a><tt class="py-lineno">292</tt>  <tt class="py-line">        <tt id="link-84" class="py-name"><a title="modbus_tk.hooks" class="py-name" href="#" onclick="return doclink('link-84', 'hooks', 'link-14');">hooks</a></tt><tt class="py-op">.</tt><tt id="link-85" class="py-name" targets="Function modbus_tk.hooks.install_hook()=modbus_tk.hooks-module.html#install_hook,Method modbus_tk.simulator_rpc_client.SimulatorRpcClient.install_hook()=modbus_tk.simulator_rpc_client.SimulatorRpcClient-class.html#install_hook"><a title="modbus_tk.hooks.install_hook
modbus_tk.simulator_rpc_client.SimulatorRpcClient.install_hook" class="py-name" href="#" onclick="return doclink('link-85', 'install_hook', 'link-85');">install_hook</a></tt><tt class="py-op">(</tt><tt class="py-name">hook_name</tt><tt class="py-op">,</tt> <tt class="py-name">self</tt><tt class="py-op">.</tt><tt class="py-name">_hooks_fct</tt><tt class="py-op">[</tt><tt class="py-name">fct_name</tt><tt class="py-op">]</tt><tt class="py-op">)</tt> </tt>
</div><a name="L293"></a><tt class="py-lineno">293</tt>  <tt class="py-line">                 </tt>
<a name="Simulator._do_uninstall_hook"></a><div id="Simulator._do_uninstall_hook-def"><a name="L294"></a><tt class="py-lineno">294</tt> <a class="py-toggle" href="#" id="Simulator._do_uninstall_hook-toggle" onclick="return toggle('Simulator._do_uninstall_hook');">-</a><tt class="py-line">    <tt class="py-keyword">def</tt> <a class="py-def-name" href="modbus_tk.simulator.Simulator-class.html#_do_uninstall_hook">_do_uninstall_hook</a><tt class="py-op">(</tt><tt class="py-param">self</tt><tt class="py-op">,</tt> <tt class="py-param">args</tt><tt class="py-op">)</tt><tt class="py-op">:</tt> </tt>
</div><div id="Simulator._do_uninstall_hook-collapsed" style="display:none;" pad="+++" indent="++++++++"></div><div id="Simulator._do_uninstall_hook-expanded"><a name="L295"></a><tt class="py-lineno">295</tt>  <tt class="py-line">        <tt class="py-docstring">"""</tt> </tt>
<a name="L296"></a><tt class="py-lineno">296</tt>  <tt class="py-line"><tt class="py-docstring">        uninstall a function as a hook. </tt> </tt>
<a name="L297"></a><tt class="py-lineno">297</tt>  <tt class="py-line"><tt class="py-docstring">        If no function is given, uninstall all functions</tt> </tt>
<a name="L298"></a><tt class="py-lineno">298</tt>  <tt class="py-line"><tt class="py-docstring">        """</tt> </tt>
<a name="L299"></a><tt class="py-lineno">299</tt>  <tt class="py-line">        <tt class="py-name">hook_name</tt> <tt class="py-op">=</tt> <tt class="py-name">args</tt><tt class="py-op">[</tt><tt class="py-number">1</tt><tt class="py-op">]</tt> </tt>
<a name="L300"></a><tt class="py-lineno">300</tt>  <tt class="py-line">        <tt class="py-keyword">try</tt><tt class="py-op">:</tt> </tt>
<a name="L301"></a><tt class="py-lineno">301</tt>  <tt class="py-line">            <tt id="link-86" class="py-name"><a title="modbus_tk.hooks" class="py-name" href="#" onclick="return doclink('link-86', 'hooks', 'link-14');">hooks</a></tt><tt class="py-op">.</tt><tt id="link-87" class="py-name" targets="Function modbus_tk.hooks.uninstall_hook()=modbus_tk.hooks-module.html#uninstall_hook,Method modbus_tk.simulator_rpc_client.SimulatorRpcClient.uninstall_hook()=modbus_tk.simulator_rpc_client.SimulatorRpcClient-class.html#uninstall_hook"><a title="modbus_tk.hooks.uninstall_hook
modbus_tk.simulator_rpc_client.SimulatorRpcClient.uninstall_hook" class="py-name" href="#" onclick="return doclink('link-87', 'uninstall_hook', 'link-87');">uninstall_hook</a></tt><tt class="py-op">(</tt><tt class="py-name">hook_name</tt><tt class="py-op">)</tt> </tt>
<a name="L302"></a><tt class="py-lineno">302</tt>  <tt class="py-line">        <tt class="py-keyword">except</tt> <tt class="py-name">KeyError</tt><tt class="py-op">,</tt> <tt class="py-name">e</tt><tt class="py-op">:</tt> </tt>
<a name="L303"></a><tt class="py-lineno">303</tt>  <tt class="py-line">            <tt id="link-88" class="py-name"><a title="modbus_tk.modbus.LOGGER
modbus_tk.modbus_rtu.LOGGER
modbus_tk.modbus_tcp.LOGGER
modbus_tk.simulator.LOGGER" class="py-name" href="#" onclick="return doclink('link-88', 'LOGGER', 'link-16');">LOGGER</a></tt><tt class="py-op">.</tt><tt class="py-name">error</tt><tt class="py-op">(</tt><tt class="py-name">str</tt><tt class="py-op">(</tt><tt class="py-name">e</tt><tt class="py-op">)</tt><tt class="py-op">)</tt> </tt>
</div><a name="L304"></a><tt class="py-lineno">304</tt>  <tt class="py-line">     </tt>
<a name="Simulator._do_set_verbose"></a><div id="Simulator._do_set_verbose-def"><a name="L305"></a><tt class="py-lineno">305</tt> <a class="py-toggle" href="#" id="Simulator._do_set_verbose-toggle" onclick="return toggle('Simulator._do_set_verbose');">-</a><tt class="py-line">    <tt class="py-keyword">def</tt> <a class="py-def-name" href="modbus_tk.simulator.Simulator-class.html#_do_set_verbose">_do_set_verbose</a><tt class="py-op">(</tt><tt class="py-param">self</tt><tt class="py-op">,</tt> <tt class="py-param">args</tt><tt class="py-op">)</tt><tt class="py-op">:</tt> </tt>
</div><div id="Simulator._do_set_verbose-collapsed" style="display:none;" pad="+++" indent="++++++++"></div><div id="Simulator._do_set_verbose-expanded"><a name="L306"></a><tt class="py-lineno">306</tt>  <tt class="py-line">        <tt class="py-docstring">"""change the verbosity of the server"""</tt> </tt>
<a name="L307"></a><tt class="py-lineno">307</tt>  <tt class="py-line">        <tt class="py-name">verbose</tt> <tt class="py-op">=</tt> <tt class="py-name">int</tt><tt class="py-op">(</tt><tt class="py-name">args</tt><tt class="py-op">[</tt><tt class="py-number">1</tt><tt class="py-op">]</tt><tt class="py-op">)</tt> </tt>
<a name="L308"></a><tt class="py-lineno">308</tt>  <tt class="py-line">        <tt class="py-name">self</tt><tt class="py-op">.</tt><tt class="py-name">server</tt><tt class="py-op">.</tt><tt id="link-89" class="py-name"><a title="modbus_tk.modbus.Master.set_verbose
modbus_tk.modbus.Server.set_verbose
modbus_tk.simulator.CompositeServer.set_verbose" class="py-name" href="#" onclick="return doclink('link-89', 'set_verbose', 'link-28');">set_verbose</a></tt><tt class="py-op">(</tt><tt class="py-name">verbose</tt><tt class="py-op">)</tt> </tt>
<a name="L309"></a><tt class="py-lineno">309</tt>  <tt class="py-line">        <tt class="py-keyword">return</tt> <tt class="py-string">"%d"</tt> <tt class="py-op">%</tt> <tt class="py-name">verbose</tt> </tt>
</div><a name="L310"></a><tt class="py-lineno">310</tt>  <tt class="py-line"> </tt>
<a name="Simulator._handle"></a><div id="Simulator._handle-def"><a name="L311"></a><tt class="py-lineno">311</tt> <a class="py-toggle" href="#" id="Simulator._handle-toggle" onclick="return toggle('Simulator._handle');">-</a><tt class="py-line">    <tt class="py-keyword">def</tt> <a class="py-def-name" href="modbus_tk.simulator.Simulator-class.html#_handle">_handle</a><tt class="py-op">(</tt><tt class="py-param">self</tt><tt class="py-op">)</tt><tt class="py-op">:</tt> </tt>
</div><div id="Simulator._handle-collapsed" style="display:none;" pad="+++" indent="++++++++"></div><div id="Simulator._handle-expanded"><a name="L312"></a><tt class="py-lineno">312</tt>  <tt class="py-line">        <tt class="py-docstring">"""almost-for-ever loop in charge of listening for command and executing it"""</tt> </tt>
<a name="L313"></a><tt class="py-lineno">313</tt>  <tt class="py-line">        <tt class="py-keyword">while</tt> <tt class="py-name">True</tt><tt class="py-op">:</tt> </tt>
<a name="L314"></a><tt class="py-lineno">314</tt>  <tt class="py-line">            <tt class="py-name">cmd</tt> <tt class="py-op">=</tt> <tt class="py-name">self</tt><tt class="py-op">.</tt><tt class="py-name">inq</tt><tt class="py-op">.</tt><tt class="py-name">get</tt><tt class="py-op">(</tt><tt class="py-op">)</tt> </tt>
<a name="L315"></a><tt class="py-lineno">315</tt>  <tt class="py-line">            <tt class="py-name">args</tt> <tt class="py-op">=</tt> <tt class="py-name">cmd</tt><tt class="py-op">.</tt><tt class="py-name">strip</tt><tt class="py-op">(</tt><tt class="py-string">'\r\n'</tt><tt class="py-op">)</tt><tt class="py-op">.</tt><tt class="py-name">split</tt><tt class="py-op">(</tt><tt class="py-string">' '</tt><tt class="py-op">)</tt> </tt>
<a name="L316"></a><tt class="py-lineno">316</tt>  <tt class="py-line">            <tt class="py-keyword">if</tt> <tt class="py-name">cmd</tt><tt class="py-op">.</tt><tt class="py-name">find</tt><tt class="py-op">(</tt><tt class="py-string">'quit'</tt><tt class="py-op">)</tt> <tt class="py-op">==</tt> <tt class="py-number">0</tt><tt class="py-op">:</tt> </tt>
<a name="L317"></a><tt class="py-lineno">317</tt>  <tt class="py-line">                <tt class="py-name">self</tt><tt class="py-op">.</tt><tt class="py-name">outq</tt><tt class="py-op">.</tt><tt class="py-name">put</tt><tt class="py-op">(</tt><tt class="py-string">'bye-bye\r\n'</tt><tt class="py-op">)</tt> </tt>
<a name="L318"></a><tt class="py-lineno">318</tt>  <tt class="py-line">                <tt class="py-keyword">break</tt> </tt>
<a name="L319"></a><tt class="py-lineno">319</tt>  <tt class="py-line">            <tt class="py-keyword">elif</tt> <tt class="py-name">self</tt><tt class="py-op">.</tt><tt class="py-name">cmds</tt><tt class="py-op">.</tt><tt class="py-name">has_key</tt><tt class="py-op">(</tt><tt class="py-name">args</tt><tt class="py-op">[</tt><tt class="py-number">0</tt><tt class="py-op">]</tt><tt class="py-op">)</tt><tt class="py-op">:</tt> </tt>
<a name="L320"></a><tt class="py-lineno">320</tt>  <tt class="py-line">                <tt class="py-keyword">try</tt><tt class="py-op">:</tt> </tt>
<a name="L321"></a><tt class="py-lineno">321</tt>  <tt class="py-line">                    <tt class="py-name">answer</tt> <tt class="py-op">=</tt> <tt class="py-name">self</tt><tt class="py-op">.</tt><tt class="py-name">cmds</tt><tt class="py-op">[</tt><tt class="py-name">args</tt><tt class="py-op">[</tt><tt class="py-number">0</tt><tt class="py-op">]</tt><tt class="py-op">]</tt><tt class="py-op">(</tt><tt class="py-name">args</tt><tt class="py-op">)</tt> </tt>
<a name="L322"></a><tt class="py-lineno">322</tt>  <tt class="py-line">                    <tt class="py-name">self</tt><tt class="py-op">.</tt><tt class="py-name">outq</tt><tt class="py-op">.</tt><tt class="py-name">put</tt><tt class="py-op">(</tt><tt class="py-string">"%s done: %s\r\n"</tt> <tt class="py-op">%</tt> <tt class="py-op">(</tt><tt class="py-name">args</tt><tt class="py-op">[</tt><tt class="py-number">0</tt><tt class="py-op">]</tt><tt class="py-op">,</tt> <tt class="py-name">answer</tt><tt class="py-op">)</tt><tt class="py-op">)</tt> </tt>
<a name="L323"></a><tt class="py-lineno">323</tt>  <tt class="py-line">                <tt class="py-keyword">except</tt> <tt class="py-name">Exception</tt><tt class="py-op">,</tt> <tt class="py-name">msg</tt><tt class="py-op">:</tt> </tt>
<a name="L324"></a><tt class="py-lineno">324</tt>  <tt class="py-line">                    <tt class="py-name">self</tt><tt class="py-op">.</tt><tt class="py-name">outq</tt><tt class="py-op">.</tt><tt class="py-name">put</tt><tt class="py-op">(</tt><tt class="py-string">"%s error: %s\r\n"</tt> <tt class="py-op">%</tt> <tt class="py-op">(</tt><tt class="py-name">args</tt><tt class="py-op">[</tt><tt class="py-number">0</tt><tt class="py-op">]</tt><tt class="py-op">,</tt> <tt class="py-name">msg</tt><tt class="py-op">)</tt><tt class="py-op">)</tt> </tt>
<a name="L325"></a><tt class="py-lineno">325</tt>  <tt class="py-line">            <tt class="py-keyword">else</tt><tt class="py-op">:</tt> </tt>
<a name="L326"></a><tt class="py-lineno">326</tt>  <tt class="py-line">                <tt class="py-name">self</tt><tt class="py-op">.</tt><tt class="py-name">outq</tt><tt class="py-op">.</tt><tt class="py-name">put</tt><tt class="py-op">(</tt><tt class="py-string">"error: unknown command %s\r\n"</tt> <tt class="py-op">%</tt> <tt class="py-op">(</tt><tt class="py-name">args</tt><tt class="py-op">[</tt><tt class="py-number">0</tt><tt class="py-op">]</tt><tt class="py-op">)</tt><tt class="py-op">)</tt> </tt>
</div><a name="L327"></a><tt class="py-lineno">327</tt>  <tt class="py-line">                 </tt>
<a name="Simulator.close"></a><div id="Simulator.close-def"><a name="L328"></a><tt class="py-lineno">328</tt> <a class="py-toggle" href="#" id="Simulator.close-toggle" onclick="return toggle('Simulator.close');">-</a><tt class="py-line">    <tt class="py-keyword">def</tt> <a class="py-def-name" href="modbus_tk.simulator.Simulator-class.html#close">close</a><tt class="py-op">(</tt><tt class="py-param">self</tt><tt class="py-op">)</tt><tt class="py-op">:</tt> </tt>
</div><div id="Simulator.close-collapsed" style="display:none;" pad="+++" indent="++++++++"></div><div id="Simulator.close-expanded"><a name="L329"></a><tt class="py-lineno">329</tt>  <tt class="py-line">        <tt class="py-docstring">"""close every server"""</tt> </tt>
<a name="L330"></a><tt class="py-lineno">330</tt>  <tt class="py-line">        <tt class="py-name">self</tt><tt class="py-op">.</tt><tt class="py-name">console</tt><tt class="py-op">.</tt><tt id="link-90" class="py-name" targets="Method modbus_tk.modbus.Master.close()=modbus_tk.modbus.Master-class.html#close,Method modbus_tk.modbus_rtu.RtuServer.close()=modbus_tk.modbus_rtu.RtuServer-class.html#close,Method modbus_tk.simulator.ConsoleInterface.close()=modbus_tk.simulator.ConsoleInterface-class.html#close,Method modbus_tk.simulator.RpcInterface.close()=modbus_tk.simulator.RpcInterface-class.html#close,Method modbus_tk.simulator.Simulator.close()=modbus_tk.simulator.Simulator-class.html#close"><a title="modbus_tk.modbus.Master.close
modbus_tk.modbus_rtu.RtuServer.close
modbus_tk.simulator.ConsoleInterface.close
modbus_tk.simulator.RpcInterface.close
modbus_tk.simulator.Simulator.close" class="py-name" href="#" onclick="return doclink('link-90', 'close', 'link-90');">close</a></tt><tt class="py-op">(</tt><tt class="py-op">)</tt> </tt>
<a name="L331"></a><tt class="py-lineno">331</tt>  <tt class="py-line">        <tt class="py-name">self</tt><tt class="py-op">.</tt><tt class="py-name">rpc</tt><tt class="py-op">.</tt><tt id="link-91" class="py-name"><a title="modbus_tk.modbus.Master.close
modbus_tk.modbus_rtu.RtuServer.close
modbus_tk.simulator.ConsoleInterface.close
modbus_tk.simulator.RpcInterface.close
modbus_tk.simulator.Simulator.close" class="py-name" href="#" onclick="return doclink('link-91', 'close', 'link-90');">close</a></tt><tt class="py-op">(</tt><tt class="py-op">)</tt> </tt>
<a name="L332"></a><tt class="py-lineno">332</tt>  <tt class="py-line">        <tt class="py-name">self</tt><tt class="py-op">.</tt><tt class="py-name">server</tt><tt class="py-op">.</tt><tt id="link-92" class="py-name"><a title="modbus_tk.modbus.Server.stop
modbus_tk.modbus_rtu.RtuServer.stop
modbus_tk.simulator.CompositeServer.stop
modbus_tk.utils.WorkerThread.stop" class="py-name" href="#" onclick="return doclink('link-92', 'stop', 'link-30');">stop</a></tt><tt class="py-op">(</tt><tt class="py-op">)</tt> </tt>
</div></div><a name="L333"></a><tt class="py-lineno">333</tt>  <tt class="py-line"> </tt>
<a name="L334"></a><tt class="py-lineno">334</tt>  <tt class="py-line"> </tt>
<a name="print_me"></a><div id="print_me-def"><a name="L335"></a><tt class="py-lineno">335</tt> <a class="py-toggle" href="#" id="print_me-toggle" onclick="return toggle('print_me');">-</a><tt class="py-line"><tt class="py-keyword">def</tt> <a class="py-def-name" href="modbus_tk.simulator-module.html#print_me">print_me</a><tt class="py-op">(</tt><tt class="py-param">args</tt><tt class="py-op">)</tt><tt class="py-op">:</tt> </tt>
</div><div id="print_me-collapsed" style="display:none;" pad="+++" indent="++++"></div><div id="print_me-expanded"><a name="L336"></a><tt class="py-lineno">336</tt>  <tt class="py-line">    <tt class="py-docstring">"""hook function example"""</tt> </tt>
<a name="L337"></a><tt class="py-lineno">337</tt>  <tt class="py-line">    <tt class="py-op">(</tt><tt class="py-name">server</tt><tt class="py-op">,</tt> <tt class="py-name">request</tt><tt class="py-op">)</tt> <tt class="py-op">=</tt> <tt class="py-name">args</tt> </tt>
<a name="L338"></a><tt class="py-lineno">338</tt>  <tt class="py-line">    <tt class="py-keyword">print</tt> <tt class="py-string">"print_me: len = "</tt><tt class="py-op">,</tt> <tt class="py-name">len</tt><tt class="py-op">(</tt><tt class="py-name">request</tt><tt class="py-op">)</tt> </tt>
</div><a name="L339"></a><tt class="py-lineno">339</tt>  <tt class="py-line"> </tt>
<a name="L340"></a><tt class="py-lineno">340</tt>  <tt class="py-line"><tt class="py-keyword">if</tt> <tt class="py-name">__name__</tt> <tt class="py-op">==</tt> <tt class="py-string">"__main__"</tt><tt class="py-op">:</tt> </tt>
<a name="L341"></a><tt class="py-lineno">341</tt>  <tt class="py-line">    <tt class="py-name">simu</tt> <tt class="py-op">=</tt> <tt id="link-93" class="py-name" targets="Class modbus_tk.simulator.Simulator=modbus_tk.simulator.Simulator-class.html"><a title="modbus_tk.simulator.Simulator" class="py-name" href="#" onclick="return doclink('link-93', 'Simulator', 'link-93');">Simulator</a></tt><tt class="py-op">(</tt><tt class="py-op">)</tt> </tt>
<a name="L342"></a><tt class="py-lineno">342</tt>  <tt class="py-line">     </tt>
<a name="L343"></a><tt class="py-lineno">343</tt>  <tt class="py-line">    <tt class="py-keyword">try</tt><tt class="py-op">:</tt> </tt>
<a name="L344"></a><tt class="py-lineno">344</tt>  <tt class="py-line">        <tt id="link-94" class="py-name"><a title="modbus_tk.modbus.LOGGER
modbus_tk.modbus_rtu.LOGGER
modbus_tk.modbus_tcp.LOGGER
modbus_tk.simulator.LOGGER" class="py-name" href="#" onclick="return doclink('link-94', 'LOGGER', 'link-16');">LOGGER</a></tt><tt class="py-op">.</tt><tt class="py-name">info</tt><tt class="py-op">(</tt><tt class="py-string">"'quit' for closing the server"</tt><tt class="py-op">)</tt> </tt>
<a name="L345"></a><tt class="py-lineno">345</tt>  <tt class="py-line">         </tt>
<a name="L346"></a><tt class="py-lineno">346</tt>  <tt class="py-line">        <tt class="py-name">simu</tt><tt class="py-op">.</tt><tt id="link-95" class="py-name" targets="Method modbus_tk.simulator.Simulator.declare_hook()=modbus_tk.simulator.Simulator-class.html#declare_hook"><a title="modbus_tk.simulator.Simulator.declare_hook" class="py-name" href="#" onclick="return doclink('link-95', 'declare_hook', 'link-95');">declare_hook</a></tt><tt class="py-op">(</tt><tt class="py-string">"print_me"</tt><tt class="py-op">,</tt> <tt id="link-96" class="py-name" targets="Function modbus_tk.simulator.print_me()=modbus_tk.simulator-module.html#print_me"><a title="modbus_tk.simulator.print_me" class="py-name" href="#" onclick="return doclink('link-96', 'print_me', 'link-96');">print_me</a></tt><tt class="py-op">)</tt> </tt>
<a name="L347"></a><tt class="py-lineno">347</tt>  <tt class="py-line">        <tt class="py-name">simu</tt><tt class="py-op">.</tt><tt id="link-97" class="py-name"><a title="modbus_tk.modbus.Server.start
modbus_tk.simulator.CompositeServer.start
modbus_tk.simulator.Simulator.start
modbus_tk.utils.WorkerThread.start" class="py-name" href="#" onclick="return doclink('link-97', 'start', 'link-29');">start</a></tt><tt class="py-op">(</tt><tt class="py-op">)</tt> </tt>
<a name="L348"></a><tt class="py-lineno">348</tt>  <tt class="py-line">             </tt>
<a name="L349"></a><tt class="py-lineno">349</tt>  <tt class="py-line">    <tt class="py-keyword">except</tt> <tt class="py-name">Exception</tt><tt class="py-op">,</tt> <tt class="py-name">excpt</tt><tt class="py-op">:</tt> </tt>
<a name="L350"></a><tt class="py-lineno">350</tt>  <tt class="py-line">        <tt class="py-keyword">print</tt> <tt class="py-name">excpt</tt> </tt>
<a name="L351"></a><tt class="py-lineno">351</tt>  <tt class="py-line">             </tt>
<a name="L352"></a><tt class="py-lineno">352</tt>  <tt class="py-line">    <tt class="py-keyword">finally</tt><tt class="py-op">:</tt> </tt>
<a name="L353"></a><tt class="py-lineno">353</tt>  <tt class="py-line">        <tt class="py-name">simu</tt><tt class="py-op">.</tt><tt id="link-98" class="py-name"><a title="modbus_tk.modbus.Master.close
modbus_tk.modbus_rtu.RtuServer.close
modbus_tk.simulator.ConsoleInterface.close
modbus_tk.simulator.RpcInterface.close
modbus_tk.simulator.Simulator.close" class="py-name" href="#" onclick="return doclink('link-98', 'close', 'link-90');">close</a></tt><tt class="py-op">(</tt><tt class="py-op">)</tt> </tt>
<a name="L354"></a><tt class="py-lineno">354</tt>  <tt class="py-line">        <tt id="link-99" class="py-name"><a title="modbus_tk.modbus.LOGGER
modbus_tk.modbus_rtu.LOGGER
modbus_tk.modbus_tcp.LOGGER
modbus_tk.simulator.LOGGER" class="py-name" href="#" onclick="return doclink('link-99', 'LOGGER', 'link-16');">LOGGER</a></tt><tt class="py-op">.</tt><tt class="py-name">info</tt><tt class="py-op">(</tt><tt class="py-string">"modbus_tk.simulator has stopped!"</tt><tt class="py-op">)</tt>             </tt>
<a name="L355"></a><tt class="py-lineno">355</tt>  <tt class="py-line">        <tt class="py-comment">#In python 2.5, the SocketServer shutdown is not working Ok</tt> </tt>
<a name="L356"></a><tt class="py-lineno">356</tt>  <tt class="py-line">        <tt class="py-comment">#The 2 lines below are an ugly temporary workaround </tt> </tt>
<a name="L357"></a><tt class="py-lineno">357</tt>  <tt class="py-line">        <tt class="py-name">time</tt><tt class="py-op">.</tt><tt class="py-name">sleep</tt><tt class="py-op">(</tt><tt class="py-number">1.0</tt><tt class="py-op">)</tt> </tt>
<a name="L358"></a><tt class="py-lineno">358</tt>  <tt class="py-line">        <tt class="py-name">sys</tt><tt class="py-op">.</tt><tt class="py-name">exit</tt><tt class="py-op">(</tt><tt class="py-op">)</tt> </tt>
<a name="L359"></a><tt class="py-lineno">359</tt>  <tt class="py-line"> </tt><script type="text/javascript">
<!--
expandto(location.href);
// -->
</script>
</pre>
<br />
<!-- ==================== NAVIGATION BAR ==================== -->
<table class="navbar" border="0" width="100%" cellpadding="0"
       bgcolor="#a0c0ff" cellspacing="0">
  <tr valign="middle">

  <!-- Tree link -->
      <th>&nbsp;&nbsp;&nbsp;<a
        href="module-tree.html">Trees</a>&nbsp;&nbsp;&nbsp;</th>

  <!-- Index link -->
      <th>&nbsp;&nbsp;&nbsp;<a
        href="identifier-index.html">Indices</a>&nbsp;&nbsp;&nbsp;</th>

  <!-- Help link -->
      <th>&nbsp;&nbsp;&nbsp;<a
        href="help.html">Help</a>&nbsp;&nbsp;&nbsp;</th>

  <!-- Project homepage -->
      <th class="navbar" align="right" width="100%">
        <table border="0" cellpadding="0" cellspacing="0">
          <tr><th class="navbar" align="center"
            ><a class="navbar" target="_top" href="http://code.google.com/p/modbus-tk/">Modbus Test Kit</a></th>
          </tr></table></th>
  </tr>
</table>
<table border="0" cellpadding="0" cellspacing="0" width="100%%">
  <tr>
    <td align="left" class="footer">
    Generated by Epydoc 3.0.1 on Wed May 26 17:43:07 2010
    </td>
    <td align="right" class="footer">
      <a target="mainFrame" href="http://epydoc.sourceforge.net"
        >http://epydoc.sourceforge.net</a>
    </td>
  </tr>
</table>

<script type="text/javascript">
  <!--
  // Private objects are initially displayed (because if
  // javascript is turned off then we want them to be
  // visible); but by default, we want to hide them.  So hide
  // them unless we have a cookie that says to show them.
  checkCookie();
  // -->
</script>
</body>
</html>
